transformers 4.26.0: Error of `from_pretrained(pretrained_model_name_or_path=None, ...)`
Author: MuMuJun97
Pull request: no

### System Info

Env:
```shell
ubuntu 20.04 
gcc --version  9.4.0
python 3.8.16
torch                           1.7.1+cu110
torch-cluster                   1.5.9
torch-geometric                 2.0.4
torch-scatter                   2.0.7
torch-sparse                    0.6.9
torch-spline-conv               1.2.1
torchvision                     0.8.2+cu110
transformers                    4.26.0
```

### Who can help?

@gante @sgugger

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Hi, when I run the following code with transformers 4.26.0, the program crashes with error:
```python
model_class = ... # self- definition model class
model = model_class.from_pretrained(
        pretrained_model_name_or_path=None, 
        config=model_config, 
        state_dict=checkpoint
)
>>>
    model = model_class.from_pretrained(
  File "/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2478, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2718, in _load_pretrained_model
    folder = os.path.sep.join(resolved_archive_file[0].split(os.path.sep)[:-1])
TypeError: 'NoneType' object is not subscriptable
python-BaseException
```

### Issues:
```python
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], *model_args, **kwargs):
    # In /lib/python3.8/site-packages/transformers/modeling_utils.py L: 2111
    def 
    if pretrained_model_name_or_path is not None:
        ...
    else:
        resolved_archive_file = None

In /lib/python3.8/site-packages/transformers/modeling_utils.py L:2718 
def _load_pretrained_model():
    folder = os.path.sep.join(resolved_archive_file[0].split(os.path.sep)[:-1]) 
```

As said in [from_pretrained API](https://huggingface.co/docs/transformers/main_classes/model#transformers.PreTrainedModel.from_pretrained.pretrained_model_name_or_path), the param `pretrained_model_name_or_path` can be None if you are both providing the configuration and state dictionary (resp. with keyword arguments `config` and `state_dict`).

### Solutions

Besides, when I run the same code with `transformers 4.12.0 + python 3.6`, the program runs fine.

For transformers 4.26.0 , the above issue can be solved by add the following code to https://github.com/huggingface/transformers/blob/820c46a707ddd033975bc3b0549eea200e64c7da/src/transformers/modeling_utils.py#L2718 
```python
        if resolved_archive_file is not None:
            folder = os.path.sep.join(resolved_archive_file[0].split(os.path.sep)[:-1])
```

Comments:
The fix might be a bit more involved to make sure it doesn't break anything else, but this looks like the essence of it. A test should also be added for this API to make sure it doesn't break again. Will try to have a look later today or tomorrow/

Thank you for your efforts!
I have modified the code for `transformers 4.26.0` and tested it on my custom model. There were no further errors and the program didn't break anything else.