Deprecate old past arguments
As discussed internally, previous arguments `past`, `decoder_cached_states` and `decoder_past_key_value_states` are deprecated and replaced by either `past_key_values` or `decoder_past_key_values`. 
This also fixes the mentions to those arguments in the input docstrings, the output docstrings already refer to the correct arg (this was done in #5226 ).

In passing, replace `DeprecationWarning` in the other deprecated args by `FutureWarning`, since it's the right way to do it.
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5671?src=pr&el=h1) Report
> Merging [#5671](https://codecov.io/gh/huggingface/transformers/pull/5671?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/201d23f2854c7a13d3c32df4947af9fd7365c2cd&el=desc) will **decrease** coverage by `0.14%`.
> The diff coverage is `68.00%`.

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

```diff
@@            Coverage Diff             @@
##           master    #5671      +/-   ##
==========================================
- Coverage   77.34%   77.20%   -0.15%     
==========================================
  Files         146      146              
  Lines       25948    25981      +33     
==========================================
- Hits        20070    20059      -11     
- Misses       5878     5922      +44     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5671?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_albert.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19hbGJlcnQucHk=) | `82.04% <ø> (ø)` | |
| [src/transformers/modeling\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19iZXJ0LnB5) | `88.39% <ø> (ø)` | |
| [src/transformers/modeling\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19kaXN0aWxiZXJ0LnB5) | `97.82% <ø> (ø)` | |
| [src/transformers/modeling\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19lbGVjdHJhLnB5) | `81.55% <ø> (ø)` | |
| [src/transformers/modeling\_longformer.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19sb25nZm9ybWVyLnB5) | `89.71% <ø> (ø)` | |
| [src/transformers/modeling\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19vcGVuYWkucHk=) | `82.31% <ø> (ø)` | |
| [src/transformers/modeling\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19yb2JlcnRhLnB5) | `95.78% <ø> (ø)` | |
| [src/transformers/modeling\_bart.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19iYXJ0LnB5) | `95.80% <60.00%> (-0.64%)` | :arrow_down: |
| [src/transformers/modeling\_t5.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190NS5weQ==) | `83.11% <60.00%> (-0.55%)` | :arrow_down: |
| [src/transformers/modeling\_ctrl.py](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19jdHJsLnB5) | `96.37% <71.42%> (-1.54%)` | :arrow_down: |
| ... and [4 more](https://codecov.io/gh/huggingface/transformers/pull/5671/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5671?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/5671?src=pr&el=footer). Last update [201d23f...f51c43e](https://codecov.io/gh/huggingface/transformers/pull/5671?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
<|||||>i was able to use gpt2 using trainer 10-12 hours ago but i am getting an error now, i think the "past" variable replacing is not consistent with the trainer.py class that's why i am getting this error(now i am working with 3.0.1)
`
TypeError                                 Traceback (most recent call last)
<ipython-input-15-3435b262f1ae> in <module>
----> 1 trainer.train()

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/transformers/trainer.py in train(self, model_path)
    497                     continue
    498 
--> 499                 tr_loss += self._training_step(model, inputs, optimizer)
    500 
    501                 if (step + 1) % self.args.gradient_accumulation_steps == 0 or (

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/transformers/trainer.py in _training_step(self, model, inputs, optimizer)
    620             inputs["mems"] = self._past
    621 
--> 622         outputs = model(**inputs)
    623         loss = outputs[0]  # model outputs are always tuple in transformers (see doc)
    624 

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--> 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py in forward(self, *inputs, **kwargs)
    151         replicas = self.replicate(self.module, self.device_ids[:len(inputs)])
    152         outputs = self.parallel_apply(replicas, inputs, kwargs)
--> 153         return self.gather(outputs, self.output_device)
    154 
    155     def replicate(self, module, device_ids):

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py in gather(self, outputs, output_device)
    163 
    164     def gather(self, outputs, output_device):
--> 165         return gather(outputs, output_device, dim=self.dim)
    166 
    167 

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py in gather(outputs, target_device, dim)
     66     # Setting the function to None clears the refcycle.
     67     try:
---> 68         res = gather_map(outputs)
     69     finally:
     70         gather_map = None

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py in gather_map(outputs)
     61             return type(out)(((k, gather_map([d[k] for d in outputs]))
     62                               for k in out))
---> 63         return type(out)(map(gather_map, zip(*outputs)))
     64 
     65     # Recursive function calls like this create reference cycles.

TypeError: __init__() missing 1 required positional argument: 'logits'
`<|||||>This is not linked to this PR, as the Trainer never uses past. It seems linked to the model output PR (#5226). You need to instantiate your model by passing `return_tuple=True` to avoid the new behavior, or by adding it to your config like this:
```
config.return_tuple = True
```
<|||||>Then why the trainer that works in 3.0.1 does not work after this PR merge.
I am new to this library and trying to understand it would be very helpful
if you explained a bit.
Thanks

On Sat, Jul 11, 2020, 6:10 PM Sylvain Gugger <notifications@github.com>
wrote:

> This is not linked to this PR, as the Trainer never uses past. It seems
> linked to the model output PR (#5226
> <https://github.com/huggingface/transformers/issues/5226>) will push a
> quick fix soon.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/pull/5671#issuecomment-657054389>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AHYJOHP4KBK2FJA2JC2J7V3R3BJEDANCNFSM4OWZ67WQ>
> .
>
<|||||>I think you mistake the PR that caused the problem, #5226 was merged just a bit before.