cleanup torch unittests
Author: stas00
Pull request: yes

a large group of tests has been modified according to the request in https://github.com/huggingface/transformers/issues/5973

If this is what's needed then just running this magic perl sequence should take care of most of them:

```
perl -pi -e 's|^\s+self.check_loss_output\(result\)\n||' tests/test_modeling_bert.py

perl -0777 -pi -e 's|^\s+def check_loss_output\(self, result\):[\s\n]+       self.parent.assertListEqual\(list\(result\["loss"\].size\(\)\), \[]\)\s*\n|\n|msg' tests/test_modeling_bert.py

perl -0777 -pi -e 's#self.parent.assertListEqual\(
[\s\n]*
list\((result\w*)\[" ([^"]+) "\].(?:shape|size\(\))\),[\s\n]+\[ ( [^\]]* ) \],?
[\s\n]*
\)
#self.parent.assertEqual($1.$2.shape, ($3))#xmsg' tests/test_modeling_bert.py
```
(edit, adjusted for multiple various inputs)

well, add:
```
make style
```
to fix the style.

problem: not all results are objects, some are plain `dict` and can't be called with .key_name. See my comment below.

@sshleifer 


Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/6196?src=pr&el=h1) Report
> Merging [#6196](https://codecov.io/gh/huggingface/transformers/pull/6196?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/82a0e2b67ec94d28b20e24b3393644002bbd0d4b&el=desc) will **decrease** coverage by `1.15%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master    #6196      +/-   ##
==========================================
- Coverage   79.65%   78.49%   -1.16%     
==========================================
  Files         146      146              
  Lines       26607    26607              
==========================================
- Hits        21194    20886     -308     
- Misses       5413     5721     +308     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/6196?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_mobilebert.py](https://codecov.io/gh/huggingface/transformers/pull/6196/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9tb2JpbGViZXJ0LnB5) | `23.38% <0.00%> (-73.39%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/6196/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `80.30% <0.00%> (+0.25%)` | :arrow_up: |
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/6196/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `86.46% <0.00%> (+5.76%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/6196/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9ncHQyLnB5) | `95.32% <0.00%> (+23.67%)` | :arrow_up: |
| [src/transformers/tokenization\_bart.py](https://codecov.io/gh/huggingface/transformers/pull/6196/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fYmFydC5weQ==) | `95.77% <0.00%> (+35.21%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/6196?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/6196?src=pr&el=footer). Last update [82a0e2b...f559e11](https://codecov.io/gh/huggingface/transformers/pull/6196?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


I added one more `check_loss_output` that was missing, no changes otherwise.

CI is randomly failing again...