Load custom models
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.3.2
- Platform: RHEL 7
- Python version: 3.7
- PyTorch version (GPU?): 1.7.0 (GPU)
- Tensorflow version (GPU?): N/A
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help
@sgugger @LysandreJik

<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.



Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @jplu

Library: 

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): A custom model

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [* ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [*] my own task or dataset: (give details below)

I created a custom model by extending the SqueezeBertPreTrainedModel and added another classification head for multi-task learning. Trained with Trainer and TrainingArguments successfully, and saved the model by calling trainer.save_model(TRAINED_MODEL_PATH). Everything worked fine.

However, when I tried to load the model by calling MyCustomModelClass.from_pretrained(TRAINED_MODEL_PATH, local_files_only=True), an error was thrown:

```
Traceback (most recent call last):
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/configuration_utils.py", line 424, in get_config_dict
    use_auth_token=use_auth_token,
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/file_utils.py", line 1086, in cached_path
    local_files_only=local_files_only,
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/file_utils.py", line 1259, in get_from_cache
    "Cannot find the requested files in the cached path and outgoing traffic has been"
FileNotFoundError: Cannot find the requested files in the cached path and outgoing traffic has been disabled. To enable model look-ups and downloads online, set 'local_files_only' to False.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ec2-user/workspaces/compressed_transformers/src/Compressed_transformers/compression/evaluate.py", line 135, in <module>
    local_files_only=True,
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/modeling_utils.py", line 962, in from_pretrained
    **kwargs,
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/configuration_utils.py", line 376, in from_pretrained
    config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/home/ec2-user/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/transformers/configuration_utils.py", line 436, in get_config_dict
    raise EnvironmentError(msg)
OSError: Can't load config for './SqueezeBert/results/best_checkpoint/config.json'. Make sure that:

- './SqueezeBert/results/best_checkpoint/config.json' is a correct model identifier listed on 'https://huggingface.co/models'

- or './SqueezeBert/results/best_checkpoint/config.json' is the correct path to a directory containing a config.json file

```

## To reproduce

Steps to reproduce the behavior:

1. Extend the SqueezeBertPreTrainedModel (maybe other PreTrainedModel classes as well) class and create a model with a dataset
2. Train the model with the dataset and save the model using trainer.save_model(MODEL_DIR)
3. Load the model by calling MyCustomModelClass.from_pretrained(MODEL_DIR)

<!-- If you have code snippets, error messages, stack traces please provide them 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.-->

## Expected behavior
It shouldn't look for models from the internet or model classes available in the library when AutoModel or AutoConfig is not used. When MyCustomModelClass.from_pretrained(MODEL_DIR) is called, it should be able to look up config.json and load the checkpoint correctly.

<!-- A clear and concise description of what you would expect to happen. -->

Hello! Could you provide a reproducible code example, for example the extended custom model you created, so that we can take a look?

Also, can you let us know what's in the `./SqueezeBert/results/best_checkpoint/` directory? It's trying to look for a configuration file there but it doesn't find it.<|||||>Thank you @LysandreJik for getting back! I have prepared a Google colab and it just ran fine: https://colab.research.google.com/drive/1SKx0DXHrgVUMFK7sk6jU05o_SnFKrc6k#scrollTo=MOijCowF3dqk

There must be something else in my code (which I can't share). Closing this now.