[WIP] Adapt lm generate fn for seq 2 seq models
Author: patrickvonplaten
Pull request: yes

From looking at the soon-to-be-added Bart model, I though the language generation could be conceptually adapted as shown below to be able to produce language from seq-to-seq models (Bart & T5). 

So far this is not tested at all and only adapted for the `_generate_no_beam_search()` function. Also it still has to be checked whether this is compatible with T5.

Would be happy about feedback @sshleifer, @thomwolf 

Comments:
Excited for this!

A little early for me to have an opinion, but I'd start by adding a bunch of failing tests (e.g. for t5.generate), and some slow tests that verify that T5.generate/another non seq2seq model generate reasonable results. (You have to run those locally). 

Stylistically, I'd say `is_seq_to_seq` should probably not be a function, just an attribute. But I think style here much less important than test coverage :)

Bon Chance!

Meant to just comment, sorry!

I adapted the language generation according to the newly added Bart file. This is still very much work in progress that's why I left a lot of comments in all files. Would be very happy about some feedback! @sshleifer 

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

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

```diff
@@             Coverage Diff             @@
##           master    #2888       +/-   ##
===========================================
- Coverage   77.12%   43.37%   -33.75%     
===========================================
  Files          98       98               
  Lines       15975    15995       +20     
===========================================
- Hits        12320     6938     -5382     
- Misses       3655     9057     +5402
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/2888?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19ncHQyLnB5) | `0% <0%> (-86.12%)` | :arrow_down: |
| [src/transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ191dGlscy5weQ==) | `0% <0%> (-92.38%)` | :arrow_down: |
| [src/transformers/modeling\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ194bG5ldC5weQ==) | `0% <0%> (-75.78%)` | :arrow_down: |
| [src/transformers/modeling\_bart.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19iYXJ0LnB5) | `0% <0%> (-84.69%)` | :arrow_down: |
| [src/transformers/modeling\_transfo\_xl.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190cmFuc2ZvX3hsLnB5) | `0% <0%> (-75.64%)` | :arrow_down: |
| [src/transformers/modeling\_ctrl.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19jdHJsLnB5) | `0% <0%> (-98.24%)` | :arrow_down: |
| [src/transformers/configuration\_bart.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9jb25maWd1cmF0aW9uX2JhcnQucHk=) | `36.36% <0%> (-63.64%)` | :arrow_down: |
| [src/transformers/configuration\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9jb25maWd1cmF0aW9uX3V0aWxzLnB5) | `96.49% <100%> (+0.03%)` | :arrow_up: |
| [src/transformers/modeling\_xlm\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ194bG1fcm9iZXJ0YS5weQ==) | `0% <0%> (-100%)` | :arrow_down: |
| [src/transformers/modeling\_camembert.py](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19jYW1lbWJlcnQucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| ... and [29 more](https://codecov.io/gh/huggingface/transformers/pull/2888/diff?src=pr&el=tree-more) | |

------

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