[RFC] Tokenizer.prepare_seq2seq_batch
Author: sshleifer
Pull request: yes

This introduces a method: `Tokenizer.prepare_seq2seq_batch` that calls batch encode plus twice and prepares inputs for seq2seq models.

The seq2seq finetuning example and some seq2seq unittests calls batch encode plus twice.  This seems like it should be the work of the tokenizer, and MarianTokenizer, BartTokenizer, T5 Tokenizer can expose/ overwrite this method.

Wondering what others think before I add tests/fix callers.


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

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

```diff
@@            Coverage Diff             @@
##           master    #4889      +/-   ##
==========================================
- Coverage   77.00%   76.96%   -0.04%     
==========================================
  Files         128      128              
  Lines       21602    21614      +12     
==========================================
+ Hits        16634    16636       +2     
- Misses       4968     4978      +10     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/4889?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/tokenization\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4889/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fdXRpbHMucHk=) | `88.68% <16.66%> (-1.02%)` | :arrow_down: |
| [src/transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4889/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ191dGlscy5weQ==) | `90.49% <0.00%> (-0.12%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4889/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl91dGlscy5weQ==) | `87.42% <0.00%> (ø)` | |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4889/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `73.49% <0.00%> (+0.40%)` | :arrow_up: |

------

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


I don't think this method is really necessary. Also, it doesn't allow to prepare decider_inputs in batches since kwargs is only given to then encoder_inputs

I agree with @patrickvonplaten .

Also I'm currently removing `trim_batch` from `tokenization_utils` since only the BART summarization example uses it.

I think it's better to keep all these small helpers in examples scripts unless you find other members of the team interested in using them as well or unless you can propose a larger modification of the general API to incorporate them seamlessly in the general abstractions we use (tokenizers, etc.).

I think @joeddav used `trim_batch`, but fine to keep it in examples/