

TITLE
get the error "_forward_unimplemented() got an unexpected keyword argument 'labels'"

COMMENTS
1

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
### System Info

```shell
- `transformers` version: 2.11.0
- Platform: Linux-5.4.0-81-generic-x86_64-with-debian-bullseye-sid
- Python version: 3.7.3
- PyTorch version (GPU?): 1.6.0+cu101 (True)
- Tensorflow version (GPU?): 2.7.1 (True)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

@LysandreJik 

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

```
class  Seq2SeqModel(nn.Module):
    def __init__(self, device):
        super(Seq2SeqModel, self).__init__()
        self.device = device
        self.tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
        self.model = BertModel.from_pretrained("bert-base-uncased")
        self.decoder = BertLMPredictionHead(self.model.embeddings.word_embeddings.weight)

    def farward(self, indexed_tokens, indexed_segment, labels, seq_len = 100):
        ones = torch.ones((1, 1, seq_len, seq_len), dtype=torch.float32, device=self.device)
        a_mask = ones.tril()
        s_ex12 = indexed_segment.unsqueeze(1).unsqueeze(2).float()
        s_ex13 = indexed_segment.unsqueeze(1).unsqueeze(3).float()
        a_mask = (1.0 - s_ex12) * (1.0 - s_ex13) + s_ex13 * a_mask
        enc_layers, _ = self.model(input_ids = indexed_tokens, token_type_ids=indexed_segment,attention_mask=a_mask,
                                   output_all_encoded_layers=True)
        squence_out = enc_layers[-1]
```

When I train the model defined above, train code like this:

```
self.bert_model = Seq2SeqModel(self.device)
_, _ = self.bert_model(token_ids,
                                            token_type_ids,
                                            labels=target_ids,
                                            device=self.device)
```

it return the error: 
`  File "/home/fanni/anaconda3/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
TypeError: _forward_unimplemented() got an unexpected keyword argument 'labels'`
I clearly defined labels and redefines the farward function， why return the error? Looking forward for your reply, thank you！

### Expected behavior

```shell
I should be able to override the 'farward' function and not be affected by the original parameters
```
