Unable to load model by ignoring size mismatch; TypeError: __init__() got an unexpected keyword argument 'ignore_mismatched_sizes'
I want to save the pre-trained model at a local path and later again load it using `from_pretrained` method. I'm doing this as I want to use hugging face on server with no internet.

I used following script to save the model:
```python3
from transformers import BertTokenizer, BertForSequenceClassification

pretrained_path = "pretrained_models/bert_base_uncased_pretrained/"

model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
model.save_pretrained(pretrained_path)
```


So I tried 2 approaches to load model from local path, but both aren't working.

### Approach 1:
Code Snippet 1:
```
model = BertForSequenceClassification.from_pretrained( 
                pretrained_path,
                num_labels = 27)
```
Error 1:
```bash
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "/path/lib/python3.6/site-packages/transformers/models/auto/auto_factory.py", line 395, in from_pretrained
    return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
  File "/path/lib/python3.6/site-packages/transformers/modeling_utils.py", line 1220, in from_pretrained
    model, state_dict, pretrained_model_name_or_path, _fast_init=_fast_init
  File "/path/lib/python3.6/site-packages/transformers/modeling_utils.py", line 1360, in _load_state_dict_into_model
    raise RuntimeError(f"Error(s) in loading state_dict for {model.__class__.__name__}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for BertForSequenceClassification:
	size mismatch for classifier.weight: copying a param with shape torch.Size([2, 768]) from checkpoint, the shape in current model is torch.Size([27, 768]).
	size mismatch for classifier.bias: copying a param with shape torch.Size([2]) from checkpoint, the shape in current model is torch.Size([27]).
```


----
### Approach 2:
Code Snippet 2:
```python3
model = BertForSequenceClassification.from_pretrained( 
                pretrained_path,
                num_labels = 27, 
                ignore_mismatched_sizes=True)
```

Error 2:
```bash
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/path/python3.6/site-packages/transformers/modeling_utils.py", line 1179, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
TypeError: __init__() got an unexpected keyword argument 'ignore_mismatched_sizes'
```

Kindly specify the way to load model with size mismatch, or any other way to save and load model from local machine every time with different number of classes.

HI, what version of transformers are you using? As `ignore_mismatched_sizes` option was newly added at v4.9.0, you should probably upgrade to v4.9.0+ in order to use it.

I tested the following snippet on Colab, it worked as expected. The transformers version I used is v4.9.0:
```
from transformers import BertTokenizer, BertForSequenceClassification

pretrained_path = "./test_path"
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
model.save_pretrained(pretrained_path)
model = BertForSequenceClassification.from_pretrained( 
                pretrained_path,
                num_labels = 27, 
                ignore_mismatched_sizes=True)
```

Output:

```
Some weights of BertForSequenceClassification were not initialized from the model checkpoint at ./test_path and are newly initialized because the shapes did not match:
- classifier.weight: found shape torch.Size([2, 768]) in the checkpoint and torch.Size([27, 768]) in the model instantiated
- classifier.bias: found shape torch.Size([2]) in the checkpoint and torch.Size([27]) in the model instantiated
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
```<|||||>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.