Unable to load from pretrained by inputting state_dict directly
### System Info

In the documentation it says that if you put the pretrained_model_name_or_path == None then you can directly input the state_dict for the model. I needed to do this for a specific use case where it doesn't make sense for me to save and then load the checkpoints like usual.  Attached is the screenshot of the documentation that says this. 

I was able to implement this functionality with very minimal changes to the code and without interfering with anything else so I would love to push this to the repository I just need the proper permissions.


![State_dict](https://github.com/huggingface/transformers/assets/13650673/856d0a3a-9a52-4db9-8c15-3aba605e9587)



### Who can help?

_No response_

### Information

- [ ] 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

When loading from_pretrained and inputting the config and state_dict but setting pretrained_model_name_or_path == None you get a None object does not have an 'endswith' method or something along those lines. 

### Expected behavior

The expected behavior is that it would load the state_dict that you input. My fixed version does this.
Hi, after reading some more online, I don't believe that this is the proper way to do a pull request. This is my first time contributing to open source. Sorry about that. I would delete this all if I was able. <|||||>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.