Getting `NameError: name 'BertOnlyMLMHead' is not defined` error when upgrading to latest transformers 
Author: gsrivas4
Pull request: no
Labels: name: Migration

# 📚 Migration

## Information

<!-- Important information -->
I am getting `NameError: name 'BertOnlyMLMHead' is not defined` error when I try to upgrade the transformers version used by [Oscar code](https://github.com/microsoft/Oscar) from pytorch-transformers to latest version of huggingface transformers.

Model I am using (Bert, XLNet ...): Bert

Language I am using the model on (English, Chinese ...): English

The problem arises when using:
* [ ] the official example scripts: (give details below) not sure
* [ ] my own modified scripts: (give details below) yes

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name): no 
* [ ] my own task or dataset: (give details below): no

## Details

<!-- A clear and concise description of the migration issue.
    If you have code snippets, please provide it 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.
    -->
I am trying to upgrade the huggingface transformers version used by [Oscar code](https://github.com/microsoft/Oscar) from pytorch-transformers to latest version of huggingface transformers. However, I am getting below error: 
```
Traceback (most recent call last):
  File "oscar/run_captioning.py", line 1010, in <module>
    main()
  File "oscar/run_captioning.py", line 966, in main
    from_tf=bool('.ckpt' in args.model_name_or_path), config=config)
  File "/usr/local/lib/python3.6/site-packages/transformers/modeling_utils.py", line 1058, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
  File "/home/default/ephemeral_drive/work/image_captioning/Oscar_13april/oscar/modeling/modeling_bert.py", line 624, in __init__
    self.cls = BertOnlyMLMHead(config)
NameError: name 'BertOnlyMLMHead' is not defined
```
I have looked into the latest transformers and seems the class is not defined. However, the class was defined in older version of transformers - https://github.com/huggingface/transformers/blob/067923d3267325f525f4e46f357360c191ba562e/pytorch_transformers/modeling_bert.py#L506-L513.

What could be a replacement of the class `BertOnlyMLMHead` when using latest version of transformers?

## Environment info
<!-- You can run the command `python transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
 
- `transformers` version: https://github.com/huggingface/transformers
- Platform: x86_64 GNU/Linux
- Python version: 3.6.8
- PyTorch version (GPU?): 1.7.0+cu101 (GPU)
- Tensorflow version (GPU?): 2.3.0 (GPU)
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

<!-- IMPORTANT: which version of the former library do you use? -->
* `pytorch-transformers` or `pytorch-pretrained-bert` version (or branch): https://github.com/huggingface/transformers/tree/067923d3267325f525f4e46f357360c191ba562e


## Checklist

- [ yes] I have read the migration guide in the readme.
 ([pytorch-transformers](https://github.com/huggingface/transformers#migrating-from-pytorch-transformers-to-transformers);
  [pytorch-pretrained-bert](https://github.com/huggingface/transformers#migrating-from-pytorch-pretrained-bert-to-transformers))
- [ no] I checked if a related official extension example runs on my machine.


Comments:
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.