Error "Expected input batch_size (16) to match target batch_size (1440)" in the WNUT NER example
Author: dr-manhattan
Pull request: no

## Environment info
- `transformers` version: 4.2.2
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.7.0+cu101 (False)
- Tensorflow version (GPU?): 2.4.1 (False)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
@joeddav 
@sgugger

## Information

Model I am using: DistilBert

The problem arises when using:
* [ x] the official example script

Steps to reproduce the behavior:

reproducing the NER example from 

https://huggingface.co/transformers/master/custom_datasets.html

verbatim (in colab) I get 
```
"Expected input batch_size (16) to match target batch_size (1440)."
```

when running trainer.train

Stack trace:
```
ValueError                                Traceback (most recent call last)
<ipython-input-12-aa1378d94d0f> in <module>()
     21 )
     22 
---> 23 trainer.train()

8 frames
/usr/local/lib/python3.6/dist-packages/transformers/trainer.py in train(self, model_path, trial)
    886                         tr_loss += self.training_step(model, inputs)
    887                 else:
--> 888                     tr_loss += self.training_step(model, inputs)
    889                 self._total_flos += self.floating_point_ops(inputs)
    890 

/usr/local/lib/python3.6/dist-packages/transformers/trainer.py in training_step(self, model, inputs)
   1248                 loss = self.compute_loss(model, inputs)
   1249         else:
-> 1250             loss = self.compute_loss(model, inputs)
   1251 
   1252         if self.args.n_gpu > 1:

/usr/local/lib/python3.6/dist-packages/transformers/trainer.py in compute_loss(self, model, inputs)
   1275         Subclass and override for custom behavior.
   1276         """
-> 1277         outputs = model(**inputs)
   1278         # Save past state if it exists
   1279         # TODO: this needs to be fixed and made cleaner later.

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--> 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

/usr/local/lib/python3.6/dist-packages/transformers/models/distilbert/modeling_distilbert.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict)
    637             else:
    638                 loss_fct = nn.CrossEntropyLoss()
--> 639                 loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
    640 
    641         if not return_dict:

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--> 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py in forward(self, input, target)
    960     def forward(self, input: Tensor, target: Tensor) -> Tensor:
    961         return F.cross_entropy(input, target, weight=self.weight,
--> 962                                ignore_index=self.ignore_index, reduction=self.reduction)
    963 
    964 

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce, reduction)
   2466     if size_average is not None or reduce is not None:
   2467         reduction = _Reduction.legacy_get_string(size_average, reduce)
-> 2468     return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
   2469 
   2470 

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce, reduction)
   2260     if input.size(0) != target.size(0):
   2261         raise ValueError('Expected input batch_size ({}) to match target batch_size ({}).'
-> 2262                          .format(input.size(0), target.size(0)))
   2263     if dim == 2:
   2264         ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

ValueError: Expected input batch_size (16) to match target batch_size (1440).
```

Comments:
I'm guessing you're running the trainer code block from the sequence classification example verbatim. You want `DistilBertForTokenClassification` not `DistilBertForSequenceClassification`, so comment out:

>  model = DistilBertForSequenceClassification.from_pretrained("distilbert-base-uncased") 

> I'm guessing you're running the trainer code block from the sequence classification example verbatim. You want `DistilBertForTokenClassification` not `DistilBertForSequenceClassification`, so comment out:
> 
> > model = DistilBertForSequenceClassification.from_pretrained("distilbert-base-uncased")

Doh. Indeed, thanks for the catch.

Had to use DistilBertForTokenClassification to reproduce the example.