Replace pad_token with -100 for LM loss calculation
Author: setu4993
Pull request: yes

The docs for both GPT and [GPT2](https://huggingface.co/transformers/model_doc/gpt2.html#gpt2lmheadmodel) specify that labels that are not -100 will be used for the calculation of the loss. So, the padding for the labels should be `-100`, not `tokenizer.pad_token_id`.

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

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

```diff
@@            Coverage Diff             @@
##           master    #4718      +/-   ##
==========================================
- Coverage   77.10%   76.45%   -0.65%     
==========================================
  Files         128      128              
  Lines       21723    21725       +2     
==========================================
- Hits        16749    16610     -139     
- Misses       4974     5115     +141     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/4718?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/data/data\_collator.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFfY29sbGF0b3IucHk=) | `89.55% <100.00%> (+0.32%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_pytorch\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9weXRvcmNoX3V0aWxzLnB5) | `8.72% <0.00%> (-81.21%)` | :arrow_down: |
| [src/transformers/modeling\_ctrl.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19jdHJsLnB5) | `96.56% <0.00%> (-2.58%)` | :arrow_down: |
| [src/transformers/modeling\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19vcGVuYWkucHk=) | `79.51% <0.00%> (-1.39%)` | :arrow_down: |
| [src/transformers/trainer.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `38.08% <0.00%> (-1.17%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl91dGlscy5weQ==) | `86.49% <0.00%> (-0.78%)` | :arrow_down: |
| [src/transformers/benchmark/benchmark\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9iZW5jaG1hcmsvYmVuY2htYXJrX3V0aWxzLnB5) | `72.80% <0.00%> (-0.30%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `73.79% <0.00%> (ø)` | |
| [src/transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4718/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ191dGlscy5weQ==) | `90.61% <0.00%> (+0.11%)` | :arrow_up: |

------

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


Closed the PR by mistake... Re-opening it.

Just a quick question for @mfuntowicz, is `copy.deepcopy` a performant way to clone a tensor? (given that this is called at each training step)

I saw `deepcopy` being used elsewhere in the code, so added it as is. Just looking at the new tensor [documentation](https://pytorch.org/docs/stable/tensors.html#torch.Tensor.new_tensor), and they recommend using `.clone().detach()`. Happy to change it to that.

Bumping this since I haven't seen any activity in a few days.

Yes `.clone().detach()` sounds good.

LGTM but let's let @LysandreJik have a last check and merge this

Thanks @julien-c!

Hey @LysandreJik, can you please review when you have a chance? Thanks!

Thanks @setu4993!