Dynamically load model code from the Hub
# What does this PR do?

This PR allows a user to upload a modeling file along their model weights, and then lets the `Auto` classes load that model. The API is still a bit manual for now, it will be smoothed in follow-up PRs.

In terms of user of the model, the only thing to add is the flag `trust_remote_code=True` when using an auto class:
```
from transformers import AutoModel

model = AutoModel.from_pretrained("sgugger/test_dynamic_model", trust_remote_code=True)
```
This will load a `FakeModel` as defined in [this file](https://huggingface.co/sgugger/test_dynamic_model/blob/main/modeling.py).

For the person uploading the model there is a tiny bit more work. First save the code of the model (with all necessary imports) in a single python file, for instance `modeling.py`. In the rest of this PR description, I'll use MODELING_FILE to represent the name of that file without the suffix (so in my example of `modeling.py`, MODELING_FILE is "modeling"). That file needs to be in the repository you upload.

Second, add a filed `auto_map` to the configuration of the model you want to upload. This needs to be a dictionary with the name of auto classes as keys, and the full name of the corresponding modeling class as values. By full name, I mean MODELING_FILE.CLASS_NAME. For instance `modeling.FakeModel` for a class `FakeModel` defined in the `modeling.py` module. Here is an example:
```
config.auto_map = {"AutoModel": "modeling.FakeModel"}
```

This needs to be done before the model is saved, so that when doing the `model.save_pretrained` call, the config is saved with that field. Once this is done, push everything to the Hub, and you should be good!
Forgive me for interjecting and asking, but does this allow custom modules to be uploaded to modelhub and loaded and run with the official Transformers library ? just to be sure.

If that's the case, do you plan to add some code scanning ? I think on some cases where this would be an security vulnerability for remote code execution<|||||>The PR requires an extra argument in the call to `from_pretrained`: `allow_custom_model=True` to execute the code from the hub. A user should not pass along that flag without having scanned the code of the repo to make sure they trust it.<|||||>Great, thanks for clearing this<|||||>hi, quick question about this PR:  

It lets people upload a custom model to the hub great, but it seems that in order to call that model using the API it still requires the model to be using one of the provided Pipelines?  Is there any way of also allowing a custom pipeline when calling the custom models? <|||||>Custom pipelines is something we will add support for, it's on the roadmap, but for now you can't use the custom model in the API indeed.