Copy code from Bert to Roberta and add safeguard script
Author: sgugger
Pull request: yes

This PR proposes some tooling to automatically check copied code from one of the files in transformers to another is consistent with the original. To showcase an example, it uses `modeling_roberta.py` where I copied all code from `modeling_bert.py` instead of importing the `BertModel` (as a result only activations are imported from `modeling_bert` and an additional refactor to put them in `activations` would make the file fully independent from `modeling_bert` but that is not the scope of this PR).

A new script called `check_copies` is introduced in the utils folder. It will check all code files for comments looking like:
```python
# Copied from transformers.modeling_bert.BertEmbeddings
```
When it encounters such a comment, it will recover the code of the object (here `BertEmbeddings`) inside its module (here `modeling_bert`) and compare it to the code in the class/function where this comment is. If there is a difference, the script will replace and overwrite (in overwrite mode) or raise an error (in checking mode). This way we can be aware of any difference when a fix is made in bert and should be ported to roberta, and we can automatically copy that difference.

The script works for classes, functions and methods. It can be called inside a function/method (if we want to add some specific initial code, see some examples below). I've tried to make the comments readable while ensuring some non-related comments could be caught (hence the `transformers.` that is not useful information),

It also has a functionality where it can replace one pattern by another, for instance:
```python
# Copied from transformers.modeling_bert.BertEmbeddings with Bert->Roberta
```
will look for a diff between the original code and the observed code after replacing all instance of Bert in the original code by Roberta (this is because we have `BertLayerNorm`, `BertPooler`, `BertEncoder`... that becomes `RobertaLayerNorm`, `RobertaPooler`, `RobertaEncoder`...). Again I tried to aim for readable comments that could still be used for the script.

I added the script in overwriting mode in `make style` and in checking mode in `make quality`. Users have to be made aware that `make style` can make destructive changes when it's run (since it will erase any modification in copied parts). I can create a new alias if we think this is too dangerous for `make style`.

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

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

```diff
@@            Coverage Diff             @@
##           master    #7219      +/-   ##
==========================================
+ Coverage   78.00%   79.54%   +1.53%     
==========================================
  Files         174      174              
  Lines       33452    33671     +219     
==========================================
+ Hits        26095    26784     +689     
+ Misses       7357     6887     -470     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/7219?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19yb2JlcnRhLnB5) | `81.17% <89.06%> (-15.92%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_funnel.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9mdW5uZWwucHk=) | `18.53% <0.00%> (-75.51%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_lxmert.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9seG1lcnQucHk=) | `22.14% <0.00%> (-72.41%)` | :arrow_down: |
| [src/transformers/activations\_tf.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9hY3RpdmF0aW9uc190Zi5weQ==) | `54.16% <0.00%> (-20.84%)` | :arrow_down: |
| [src/transformers/tokenization\_dpr.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fZHByLnB5) | `53.15% <0.00%> (-4.51%)` | :arrow_down: |
| [src/transformers/modeling\_xlm.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ194bG0ucHk=) | `88.77% <0.00%> (-2.55%)` | :arrow_down: |
| [...rc/transformers/data/datasets/language\_modeling.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFzZXRzL2xhbmd1YWdlX21vZGVsaW5nLnB5) | `94.11% <0.00%> (+1.17%)` | :arrow_up: |
| [src/transformers/configuration\_longformer.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9jb25maWd1cmF0aW9uX2xvbmdmb3JtZXIucHk=) | `100.00% <0.00%> (+25.00%)` | :arrow_up: |
| [src/transformers/modeling\_longformer.py](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19sb25nZm9ybWVyLnB5) | `71.60% <0.00%> (+51.89%)` | :arrow_up: |
| ... and [4 more](https://codecov.io/gh/huggingface/transformers/pull/7219/diff?src=pr&el=tree-more) | |

------

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


- For the tests, I'm not sure what you had in mind. I could create a dumb file that I then compare to the lib.
- It does not matter if this is run before or after `black`: if there is a very long model name, the script will detect differences as soon as black as indeed been run (so it may pass if run before black once but fail at the next CI). Running it after makes sure we don't catch trailing spaces or bad empty lines (empty lines with spaces) in the diff. But this all won't work for replacement of short model names to very long model names (so sadly, we can't have `BertForGenerationAndComputerVisionBoundingBoxesForVisualQuestionAnswering` in the lib).

- Regarding the tests, I think it would be a requirement given that the script modifies the code when ran with `overwrite`. Testing to ensure it works correctly seems necessary.
- I think it could work with a bit of plumbing: given that the script registers the name change `Bert->Roberta`, the script could change the copied file from `Roberta` to `Bert`, run `black` to correctly format, and check equivalence then. I haven't though much about edge cases but it seems robust enough to me. What do you think?


This is great! Very much in favor of this PR :-)