Added data collator for permutation (XLNet) language modeling and related calls
Author: shngt
Pull request: yes

Added `DataCollatorForPermutationLanguageModeling` in `data/data_collator.py` to return necessary inputs (applies masking and generates revelant tensors input_ids, perm_mask, target_mask and labels as per https://github.com/zihangdai/xlnet/blob/master/data_utils.py) for language modeling training with XLNetLMHeadModel. Also added related arguments, logic and calls in `examples/language-modeling/run_language_modeling.py`. Defined a separate `--plm_probability` flag for its use.

Also looked into CTRL - it uses a CLM loss just like GPT and GPT-2, so should work out of the box with this script (provided `past` is taken care of similar to `mems` for XLNet). Added a few words in the comments to reflect this.

Changed calls and imports appropriately.

Resolves: #4739, #2008 (partially)

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

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

```diff
@@            Coverage Diff             @@
##           master    #5522      +/-   ##
==========================================
- Coverage   77.83%   75.79%   -2.05%     
==========================================
  Files         141      141              
  Lines       24634    24682      +48     
==========================================
- Hits        19175    18708     -467     
- Misses       5459     5974     +515     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5522?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/data/data\_collator.py](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL2RhdGFfY29sbGF0b3IucHk=) | `19.81% <14.58%> (-78.60%)` | :arrow_down: |
| [src/transformers/\_\_init\_\_.py](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9fX2luaXRfXy5weQ==) | `99.22% <100.00%> (ø)` | |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `26.92% <0.00%> (-68.47%)` | :arrow_down: |
| [src/transformers/tokenization\_xlm.py](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25feGxtLnB5) | `16.26% <0.00%> (-66.67%)` | :arrow_down: |
| [...rc/transformers/data/datasets/language\_modeling.py](https://codecov.io/gh/huggingface/transformers/pull/5522/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/5522/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/5522/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/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `16.66% <0.00%> (-21.30%)` | :arrow_down: |
| [src/transformers/data/processors/glue.py](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9kYXRhL3Byb2Nlc3NvcnMvZ2x1ZS5weQ==) | `32.00% <0.00%> (-17.10%)` | :arrow_down: |
| ... and [7 more](https://codecov.io/gh/huggingface/transformers/pull/5522/diff?src=pr&el=tree-more) | |

------

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


@patrickvonplaten Please review

Hey @shngt - Thanks a mille for your PR. Pretraining for XLNet is not easy at all, so this is a super valuable PR :-) 

Just re-read the paper and looked into the official xlnet code -> I think I finally understand now how it works exactly :D 
Because it's not at all straight-forward to understand what happens there, it would be great if we can try to make the code as understandable as possible -> that's why I left so many comments mainly on variable names.

Also, we should add a test to `test_trainer.py` to next to the other data collators to test this one :-) 

Looking forward to merge this soon :-) 

@patrickvonplaten I've added more detailed comments and fixed the naming issues. I also added a few tests based on what I could see in `tests/test_trainer.py`. Let me know what you think :)

Awesome job @shngt ! This looks very clean now :-) Good to merge IMO.
Pinging @julien-c @LysandreJik @sgugger. 

Pinging @thomwolf and @julien-c for notification and merging - Great job @shngt!

Impressive work, I was following this from the beginning.

Can we continue training XLNet now on domain-specific corpus ? and when will this merge be available to use? 

Thanks

PR should be ready for use as of now, if you install from master :-) 

Great work @shngt, this is very nice.

Hi, I raised an issue here #22435 because I have a question about this `DataCollatorForPermutationLanguageModeling`. Looking forward to your guys' response. Thank you!