from_pretrained() breaks with empty state_dict and model path as None
### System Info

- `transformers` version: 4.26.1
- Platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.35
- Python version: 3.10.6
- Huggingface_hub version: 0.12.0
- PyTorch version (GPU?): 1.12.1+cu116 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help?

@ArthurZucker @youne

### 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

To reproduce the behavior, you can run this snippet of code:

```py
from transformers import GPTJConfig, AutoModelForCausalLM
from collections import OrderedDict

config = GPTJConfig(
    n_positions=128,
    n_embd=16,
    n_layer=2,
    n_head=2
)

AutoModelForCausalLM.from_pretrained(
    None, config=config, state_dict=OrderedDict()
)
```

### Expected behavior

The expected behavior from this is to allow a model to be initialized from scratch with an empty `state_dict` and `None` as the pretrained model. There is a [tool that I am working with](https://github.com/coreweave/tensorizer) that is broken due to a regression that was introduced around version 4.23.1. From the trace of running the reproduction code, a PR that handles the case when `resolved_archive_file` and the pretrained model path are `None` would fix this issue.

It also seems that this issue is related: https://github.com/huggingface/transformers/issues/21526
This was fixed by #21542. You will need to install from source while the fix makes it way to the next release.<|||||>The PR didn't seem to fix the issue, I get a different error this time but the reproduction code still throws an error with the latest changes from source<|||||>Indeed, the fix was incomplete for generative models. The PR linked above should fully fix it.