[seq2seq] pack_dataset.py rewrites dataset in max_tokens format
Author: sshleifer
Pull request: yes

Inspired by fairseq max_tokens_dataset.
This works on disk, by regenerating the data directory, so it can work with or without @Pradhy729 's PR.
It is especially useful for avoiding padding computation in a multigpu setup, where SortishSampler doesn't work.

It will also play nice with TPU by allowing us to always of the same `input_ids` shape, rather than trimming batches to avoid padding computation.

Empirically, it reduces epoch time for mbart finetuning on 8GPU from 2.5hrs to 1.5 hrs. (You can increase batch size to 8 from 4), by cutting the number of examples by a factor of 2, and spending a bit more time on each example.

It also doesn't lead to that much more truncation than the previous approach, although I haven't quantified this.

### Example
```
wget https://s3.amazonaws.com/datasets.huggingface.co/translation/wmt_en_ro_128.tgz
tar -czvf wmt_en_ro_128.tgz
```
Creates a directory called `wmt_en_ro_packed/` with fewer examples


### Usage
```bash
python pack_dataset.py --tok_name facebook/mbart-large-en-ro --max_seq_len 128 --data_dir wmt_en_ro --save_path wmt_en_ro_packed_128
```
Output:
```bash
100%|██████████████████████████████████████████| 1999/1999 [00:01<00:00, 1533.19it/s]
packed val split from 1999 examples -> 683.
100%|██████████████████████████████████████████| 1999/1999 [00:01<00:00, 1590.80it/s]
packed test split from 1999 examples -> 652.
```

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

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

```diff
@@            Coverage Diff             @@
##           master    #5819      +/-   ##
==========================================
- Coverage   78.59%   76.96%   -1.63%     
==========================================
  Files         146      146              
  Lines       26047    26047              
==========================================
- Hits        20471    20047     -424     
- Misses       5576     6000     +424     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5819?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/data/data\_collator.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFfY29sbGF0b3IucHk=) | `19.81% <0.00%> (-79.28%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9vcGVuYWkucHk=) | `20.27% <0.00%> (-74.92%)` | :arrow_down: |
| [...rc/transformers/data/datasets/language\_modeling.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFzZXRzL2xhbmd1YWdlX21vZGVsaW5nLnB5) | `34.69% <0.00%> (-57.15%)` | :arrow_down: |
| [src/transformers/data/datasets/glue.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFzZXRzL2dsdWUucHk=) | `50.74% <0.00%> (-35.83%)` | :arrow_down: |
| [src/transformers/trainer\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyX3V0aWxzLnB5) | `60.00% <0.00%> (-25.72%)` | :arrow_down: |
| [src/transformers/trainer.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `16.51% <0.00%> (-21.34%)` | :arrow_down: |
| [src/transformers/data/processors/glue.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL3Byb2Nlc3NvcnMvZ2x1ZS5weQ==) | `32.00% <0.00%> (-17.10%)` | :arrow_down: |
| [src/transformers/training\_args.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmluZ19hcmdzLnB5) | `66.32% <0.00%> (-11.23%)` | :arrow_down: |
| [src/transformers/tokenization\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fcm9iZXJ0YS5weQ==) | `95.89% <0.00%> (-2.74%)` | :arrow_down: |
| [src/transformers/tokenization\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25feGxuZXQucHk=) | `88.28% <0.00%> (-1.81%)` | :arrow_down: |
| ... and [5 more](https://codecov.io/gh/huggingface/transformers/pull/5819/diff?src=pr&el=tree-more) | |

------

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