mypy typing not working for AutoModelForMaskedLM when used with Trainer
### System Info

Python version - 3.9
transformers version - 4.20.1

### Who can help?

@sgugger

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

1. Initialise `AutoModelForMaskedLM` 
model = `AutoModelForMaskedLM.from_pretrained("xlm-roberta-base")`

2. Pass this to the Trainer
```
trainer = Trainer(
            model= model,
            args=training_config,
            train_dataset=train_data,
            eval_dataset=valid_data,
            callbacks=None,
            data_collator=masking_processor
        )
```

3. If you check this against mypy, it produces an error stating 
`error: Argument "model" to "Trainer" has incompatible type "AutoModelForMaskedLM"; expected "Union[PreTrainedModel, Module]"`

The model is defined as `model: Union[PreTrainedModel, nn.Module] = None` in the Trainer class.

### Expected behavior

Since it's a valid input to the Trainer class, it should expect the models from AutoModel classes as well.
Hi there @harshit-sethi09 👋 Our code has type annotations, but they are mostly for documentation purposes (and not to be used with `mypy`)

cc @sgugger <|||||>I have very strong thoughts about trying to statically type-checking a dynamically typed language which would take too long to express here. But this is what you get as a result: an object will actually never be of type `AutoModel` has those can only be instantiated via classmethods which actually return other classes, a thing the static type-checker is of course incapable to see. 

We could pollute the code with tons of useless annotations to please the almighty static typechecker but we have chosen not to :-)<|||||>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/main/CONTRIBUTING.md) are likely to be ignored.