Errors in running Perceiver example with transformers-4.14.0.dev0
Author: lixiangchun
Pull request: no

Python3.8, torch-1.7.1, transformers-4.14.0.dev0

Errors in running example on https://huggingface.co/docs/transformers/model_doc/perceiver

```python
from transformers import PerceiverTokenizer, PerceiverForMaskedLM
import torch
tokenizer = PerceiverTokenizer.from_pretrained('deepmind/language-perceiver')
model = PerceiverForMaskedLM.from_pretrained('deepmind/language-perceiver')
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
```

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/software/install/miniconda38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/software/install/miniconda38/lib/python3.8/site-packages/transformers/models/perceiver/modeling_perceiver.py", line 950, in forward
    masked_lm_loss = loss_fct(logits.view(-1, self.config.vocab_size), labels.view(-1))
  File "/opt/software/install/miniconda38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/software/install/miniconda38/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 961, in forward
    return F.cross_entropy(input, target, weight=self.weight,
  File "/opt/software/install/miniconda38/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 "/opt/software/install/miniconda38/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 (2048) to match target batch_size (33).




Comments:
Hi,

Thanks for your interest in Perceiver! The reason you're getting an error is because the `logits` that come out of the model have a sequence length of 2048, as the decoder of `PerceiverForMaskedLM` defines a sequence length of 2048 which you can see [here](https://github.com/huggingface/transformers/blob/a94105f95fb66ee4129077c03e4e8a224f6a07fd/src/transformers/models/perceiver/modeling_perceiver.py#L888). It means that 2048 trainable position embeddings are used to decode the final hidden states of the latents into language modeling predictions.

Perceiver was trained with a max sequence length of 2048 bytes, hence it's advised to follow the same regime:

```
from transformers import PerceiverTokenizer, PerceiverForMaskedLM
import torch

tokenizer = PerceiverTokenizer.from_pretrained('deepmind/language-perceiver')
model = PerceiverForMaskedLM.from_pretrained('deepmind/language-perceiver')

inputs = tokenizer("The capital of France is [MASK].", padding="max_length", return_tensors="pt")
labels = tokenizer("The capital of France is Paris.", padding="max_length", return_tensors="pt")["input_ids"]

outputs = model(**inputs, labels=labels)
loss = outputs.loss
logits = outputs.logits
```

We'll update the code examples.