Cannot fine-tune google/mobilebert-uncased using native Pytorch
## Environment info
- `transformers` version: 4.12.5
- Platform: Linux-4.4.0-210-generic-x86_64-with-glibc2.23
- Python version: 3.9.7
- PyTorch version (GPU?): 1.10.0 (False)
- Tensorflow version (GPU?): 2.4.1 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help
@LysandreJik  @sgugger

## To reproduce

Steps to reproduce the behavior:

1. Follow the "fine-tuning in native PyTorch" section in "Fine-tuning a pretrained model" on the official documentation
2. Replace "bert-base-cased" with "google/mobilebert-uncased"
3. Add max_length=171 argument to tokenize function

## Expected behavior

The model fine-tuned with native PyTorch reach the same accuracy as the model fine-tuned with a Trainer. But instead the accuracy stucks around 50% and even dropped after one epoch.

I am wondering if the huggingface Trainer class used some training techniques that I must add in native PyTorch in order for the model to be properly fine-tuned. I looked into the Trainer class but didn't find anything special. Any help is appreciated.
Hi,

For training-related questions, please refer to the forum. See [here](https://discuss.huggingface.co/search?q=mobilebert) for all MobileBERT-related questions for instance.

We like to keep Github issues for bugs/feature requests.

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