Example code for ReformerForMaskedLM
## 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: 4.4.2
- Platform: Linux
- Python version: 3.8
- PyTorch version (GPU?): 1.7.1[11.0]
- Tensorflow version (GPU?):
- 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.
@patrickvonplaten
Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

Model hub:

- for issues with a model report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): ReformerForMaskedLM

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

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

## To reproduce

Steps to reproduce the behavior:
Running the example code for ReformerForMaskedLM:
```
from transformers import ReformerTokenizer, ReformerForMaskedLM
import torch

tokenizer = ReformerTokenizer.from_pretrained('google/reformer-crime-and-punishment')
model = ReformerForMaskedLM.from_pretrained('google/reformer-crime-and-punishment')

inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt")
labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits
```
causes:
```AssertionError: If you want to use `ReformerForMaskedLM` make sure `config.is_decoder=False` for bi-directional self-attention.```

<!-- 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. -->

That is not a bug:
https://stackoverflow.com/questions/66625945/huggingfaces-reformerformaskedlm-configuration-issue/66636363#66636363<|||||>Unfortunately that did not help.  Adding:
```from transformers import ReformerTokenizer, ReformerForMaskedLM, ReformerConfig
import torch

tokenizer = ReformerTokenizer.from_pretrained('google/reformer-crime-and-punishment')
config = ReformerConfig.from_pretrained('google/reformer-crime-and-punishment')
config.is_decoder=False
model = ReformerForMaskedLM.from_pretrained('google/reformer-crime-and-punishment', config=config)

inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt")
labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits```

caused this exception:
```Traceback (most recent call last):
  File "testReformers.py", line 13, in <module>
    outputs = model(**inputs, labels=labels)
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/transformers/models/reformer/modeling_reformer.py", line 2367, in forward
    masked_lm_loss = loss_fct(logits.view(-1, self.config.vocab_size), labels.view(-1))
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 961, in forward
    return F.cross_entropy(input, target, weight=self.weight,
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/torch/nn/functional.py", line 2468, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/mnt/nfs/d4nvme0/userhomes/ksrinivs/anaconda3/envs/reformers/lib/python3.8/site-packages/torch/nn/functional.py", line 2261, in nll_loss
    raise ValueError('Expected input batch_size ({}) to match target batch_size ({}).'
ValueError: Expected input batch_size (21) to match target batch_size (17).```.

Something seems amiss here given that there is a single sentence being passed in and it seems to think we have batch sizes of 21 and 17?<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.