data_collator.py - line 326, in mask tokens - xlnet finetuning error
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: version: 3.2.0
- Platform: Linux-4.15.0-118-generic-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.5.1+cu101 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.
  
 
 --> TransfoXL/XLNet: @TevenLeScao 

## Information

Model I am using (XLNet):

The problem arises when using:
* [ x] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

Testing simple example in 'language-modeling/examples/README'  using recommended wiki-2-raw dataset and xlnet-base cased model

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x ] my own task or dataset: (give details below)

Same error occurs using simple one sentence per line text file (10 megs)

## To reproduce

Steps to reproduce the behavior:

1. Run all steps in 'language-modeling/examples/README' using xlnet-base-cased (cached or local)
2. Model loads with warnings and process begins before quickly exiting with the following error:

File "/home/pixelhead/Desktop/xlnet/transformers-master/transformers/data/data_collator.py", line 326, in mask_tokens
    "This collator requires that sequence lengths be even to create a leakage-free perm_mask. Please see relevant comments in source code for details."
ValueError: This collator requires that sequence lengths be even to create a leakage-free perm_mask. Please see relevant comments in source code for details.
Epoch:   0%|                                              | 0/3 [00:00<?, ?it/s]
Iteration:   0%|

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->

Expect 'run_language_modeling.py' to work for xlnet as per 'language-modeling/examples/README'
Have tested addition of '--line_by_line' and 'block_size=128, 256, 512'  etc. Same error.

Could be missing something here 'Please see relevant comments in source code for details.' but not clear.

Cheers,
@sgugger might be interested in this issue as well.<|||||>I have the same issue. 
Does anybody know any "workarounds" to bypass this issue? <|||||>@GenTxt did you find any workaround for this error ?<|||||>No, unfortuantely. Was hoping others more familiar with the problem would
offer solutions.

On Wed, Oct 7, 2020 at 8:46 AM Mihai Dobri <notifications@github.com> wrote:

> @GenTxt <https://github.com/GenTxt> did you find any workaround for this
> error ?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/7341#issuecomment-704910726>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFMAWPJSWOH7MWHGL52UXATSJRPJHANCNFSM4RXDWVGA>
> .
>
<|||||>@LysandreJik  or @sgugger I am wondering if you could please let us know if is a workaround for this issue ? or if a code fix is planned in the near future?<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>Solved by using TPU instructions on GPU:

**Note:** On TPU , you should use the flag `--pad_to_max_length` in conjunction with the `--line_by_line` flag to make
sure all your batches have the same length.

Works now.

Encountered similar issue with fine-tuning Bert. 

Solved by using:

 --max_seq_length=512 with --line_by_line<|||||>How to solve the proble

ile "/anaconda3/envs/pytorch-gpu/lib/python3.6/site-packages/transformers/data/data_collator.py", line 615, in mask_tokens
    "This collator requires that sequence lengths be even to create a leakage-free perm_mask. Please see relevant comments in source code for details."
ValueError: This collator requires that sequence lengths be even to create a leakage-free perm_mask. Please see relevant comments in source code for details.
  0%|                                                                                      <|||||>I ended up adding <pad> if token length is not even. Is this ok?