How can I share a pytorch saved model on huggingFace hub

Hello

I have fine-tunned a Roberta-Large model and after fine-tunning i have saved it using torch.save resulting in a .pt file. Now i would like to share my fine-tunned model on huggingFace’s hub, but i need a config.json file and some other files.

i know that these files are given as a result of using model.save_pretrained, but the problem is that i get an error when i try to execute model.save_pretrained

Can you help me?

Thanks in advanced

 class ROBERTAClassifier(PreTrainedModel):
    def __init__(self, n_classes=3, dropout_rate=0.1):
        super(ROBERTAClassifier, self).__init__()
                # Specify hidden size of BERT, hidden size of our classifier, and number of labels
        H=50
        D_out=n_classes
        D_in=1024
        self.roberta = RobertaModel.from_pretrained('roberta-large',return_dict=False)
        self.classifier = nn.Sequential(
        nn.Linear(D_in, D_in),
        nn.Dropout(dropout_rate),
        nn.Linear(D_in, D_out)
        )

    def forward(self, input_ids, attention_mask):
        # Feed input to BERT
        outputs = self.roberta(input_ids=input_ids,attention_mask=attention_mask)
        
        # Extract the last hidden state of the token `[CLS]` for classification task
        last_hidden_state_cls = outputs[0][:, 0, :]

        # Feed input to classifier to compute logits
        logits = self.classifier(last_hidden_state_cls)

        return logits


device = torch.device("cpu")
model=ROBERTAClassifier()
#model= RobertaModel.from_pretrained('roberta-large',return_dict=False)
tokenizer = RobertaTokenizer.from_pretrained('roberta-large')

pt_model = RobertaForSequenceClassification.from_pretrained("path/to/awesome-name-you-picked", from_tf=False)
pt_model.save_pretrained("path/to/awesome-name-you-picked")

model=load_checkpoint(file_path + '/model.pt', model)
model.save_pretrained("my path")

#model=RobertaModel.from_pretrained(file_path + '/model.pt')
#model.from_pretrained(file_path + '/model.pt)`