Improve PreTrainedModel.from_pretrained return type
### System Info

transformers version: `main`
Platform: macOS 13.1 (x86_64)
Python version: 3.7.15
PyTorch version (GPU?): 1.13.0 (False)
Tensorflow version (GPU?): N/A
Using GPU in script?: No
Using distributed or parallel set-up in script?: No

### Who can help?

Documentation: @sgugger, @stevhliu and @MKhalusova

### Information

- [X] The official example scripts
- [ ] 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

```python
import transformers

bert_model = transformers.BertForSequenceClassification.from_pretrained("...")

reveal_type(bert_model)
# expected: BertForSequenceClassification
# actual: tuple[Unknown | BertForSequenceClassification, dict[str, Unbound | Unknown] | dict[str, Unknown | list[Unknown]] | Unknown] | Unknown | BertForSequenceClassification
```

### Expected behavior

The hinted type of the return from `from_pretrained` should be the same type as the class.

I know we could just annotate `from_pretained` to return `typing.Self`... but IMO this points to a lack of typing in a core part of `transformers`, and I think it would make this core code more robust if the static type checkers agreed that that is the correct return type (since there may be type errors lurking).
Transformers does not support any type-checker and we do not want to bloat the code to add support for them: we accept PRs adding simple annotations but we will refuse anything more complex than that.<|||||>> Transformers does not support any type-checker and we do not want to bloat the code to add support for them: we accept PRs adding simple annotations but we will refuse anything more complex than that.

I can understand your position of not wanting to bloat the code. It definitely seems reasonable if that is an established philosophy for huggingface internal APIs. I think for user-facing APIs, though, it could be beneficial to have more advanced type hints so that the average user's IDE will tell them what type of object they are dealing with when loading their model, rather than seeing a confusing, gigantic type union.

I was originally planning to submit all the work I had done to fix the type issues in `from_pretrained`, but I would be happy to leave it at just improving the signature of `PretrainedModel.from_pretrained` if you will be willing to consider it: https://github.com/huggingface/transformers/pull/24035<|||||>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.