Cleaning TensorFlow models
Author: LysandreJik
Pull request: yes

While writing docstrings for #5036, I stumbled upon a few bugs in TensorFlow, especially related to the loss computation. I'm patching them in this PR.

Here's the list of the bugs solved:

### Loss computation

- The loss is computed differently than it is with the PyTorch models. Here it is returned example-wise (therefore with a shape of `(batch_size,)`, whereas the PyTorch models return the loss as a scalar. @jplu is there a reason for this implementation?
- The TensorFlow models should be able to handle three types of scenarios: keyword arguments, dictionary, and tuple/list. Right now the `labels` can only be passed through the keyword argument. This PR changes that, and adds a test.

### Missing models in the test files

A few models were implemented but were not tested. Some of these models were not working as expected, therefore they've been updated.

- TF DistilBERT for multiple choice (added test and patched)
- TF DistilBERT for token classification
- TF Electra for QA
- TF RoBERTa for multiple choice
- TF XLNet for multiple choice (added test and patched)

### Misc

- Most of the QA models had `is_impossible`, `cls_index` and `p_mask` in their signature while not making use of them. These have been removed. **Users relying on the order of arguments in the signature will be affected by this**
- The `labels` were generally placed before the `output_attentions` and `output_hidden_states` that have recently been added to the models. This resulted in an error in the documentation as the `labels` (part of the head model) were added after the `output_attentions` and `output_hidden_states` (part of the base model). The arguments have been re-ordered to once again respect the order of `**base_arguments, **head_arguments`

Comments:
Thanks @LysandreJik !

> The loss is computed differently than it is with the PyTorch models. Here it is returned example-wise (therefore with a shape of (batch_size,), whereas the PyTorch models return the loss as a scalar. @jplu is there a reason for this implementation?

Because it is the generic approach to use as some of the other reductions are not compliant with custom training loop. For example I see that you have used `SUM_OVER_BATCH_SIZE` instead of `None` but this removes the compatibility with custom training loops like we have in the trainer, see the [doc](https://www.tensorflow.org/api_docs/python/tf/keras/losses/Reduction). Then can you undo this part please.

I do the reduction then directly in the trainer and not in the model, but we can do the reduction manually inside either the loss functions, or the `call` methods as you wish :)

> The TensorFlow models should be able to handle three types of scenarios: keyword arguments, dictionary, and tuple/list. Right now the labels can only be passed through the keyword argument. This PR changes that, and adds a test.

Good catch, thanks for having fixed this!

> Most of the QA models had is_impossible, cls_index and p_mask in their signature while not making use of them. These have been removed. Users relying on the order of arguments in the signature will be affected by this

Ok, I didn't know, when I reworked the TF models, I mostly took examples on the list of parameters from the PT part at a time T, I should have been more carefull on later changes. Sorry.

> The labels were generally placed before the output_attentions and output_hidden_states that have recently been added to the models. This resulted in an error in the documentation as the labels (part of the head model) were added after the output_attentions and output_hidden_states (part of the base model). The arguments have been re-ordered to once again respect the order of **base_arguments, **head_arguments

Thanks!! Like previously I should have been more careful on recent changes. My bad.

Okay, thanks for the review @jplu, I'll revert that part.

I'll update the documentation in the next PR

# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=h1) Report
> Merging [#5229](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/c01480bba3b2f0bd8516679476235f4701c21b3b&el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `89.06%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5229/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=tree)

```diff
@@           Coverage Diff            @@
##           master    #5229    +/-   ##
========================================
  Coverage   77.98%   77.99%            
========================================
  Files         138      138            
  Lines       23839    24014   +175     
========================================
+ Hits        18592    18729   +137     
- Misses       5247     5285    +38     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_albert.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9hbGJlcnQucHk=) | `75.63% <51.85%> (+0.40%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `95.29% <71.42%> (+4.83%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9yb2JlcnRhLnB5) | `92.82% <86.66%> (+18.33%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9iZXJ0LnB5) | `98.76% <100.00%> (+3.96%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `98.74% <100.00%> (+16.21%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_mobilebert.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9tb2JpbGViZXJ0LnB5) | `96.72% <100.00%> (+3.52%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_xlm.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl94bG0ucHk=) | `77.90% <100.00%> (+2.18%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl94bG5ldC5weQ==) | `91.77% <100.00%> (+11.92%)` | :arrow_up: |
| [src/transformers/data/data\_collator.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFfY29sbGF0b3IucHk=) | `25.00% <0.00%> (-73.34%)` | :arrow_down: |
| [...rc/transformers/data/datasets/language\_modeling.py](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFzZXRzL2xhbmd1YWdlX21vZGVsaW5nLnB5) | `34.69% <0.00%> (-57.15%)` | :arrow_down: |
| ... and [16 more](https://codecov.io/gh/huggingface/transformers/pull/5229/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=footer). Last update [c01480b...15321a4](https://codecov.io/gh/huggingface/transformers/pull/5229?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


That's awesome, thanks @LysandreJik !