Can we use trainer api with custom model layer?
I am trying to use huggin face trainer API, For example, my model looks like this:

```
class BERTClass(torch.nn.Module):
    def __init__(self):
        super(BERTClass, self).__init__()
        self.l1 = AutoModel.from_pretrained("distilbert-base-uncased",return_dict=False)
        self.l2 = torch.nn.Dropout(0.2)
        self.l3 = torch.nn.Linear(768, 50)
    
    def forward(self, ids, mask, token_type_ids):
        _, output_1= self.l1(ids, attention_mask = mask, token_type_ids = token_type_ids)
        output_2 = self.l2(output_1)
        output = self.l3(output_2)
        return output

model = BERTClass()
```

Is it possible to utilize the trainer API for custom models? such as :

trainer = Trainer(
    model=model,                         # the instantiated 🤗 Transformers model to be trained
    args=training_args,                  # training arguments, defined above
    train_dataset=train_dataset,         # training dataset
    eval_dataset=val_dataset             # evaluation dataset
)

trainer.train()


Yes you can. As mentioned in the [docs](https://huggingface.co/transformers/main_classes/trainer.html):

> When using it on your own model, make sure:
> your model always return tuples or subclasses of ModelOutput.
> your model can compute the loss if a labels argument is provided and that loss is returned as the first element of the tuple (if your model returns tuples)
> your model can accept multiple label arguments (use the label_names in your TrainingArguments to indicate their name to the Trainer) but none of them should be named "label".