Fix from_pretrained API with config and state_dict
# What does this PR do?

The `from_pretrained` method documents its possible to pass along `pretrained_model_name_or_path=None` as long the user provides a `config` and a `state_dict`. This API was not tested and broke, this PR fixes that and adds a test.

Fixes #21526 
_The documentation is not available anymore as the PR was closed or merged._