Calling `AutoModel.from_config()` method for a model requiring timm does not raise ImportError although it should
### System Info

- `transformers` version: 4.26.0.dev0
- Platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.35
- Python version: 3.9.12
- Huggingface_hub version: 0.11.0.dev0
- PyTorch version (GPU?): 1.12.1+cu102 (True)
- Tensorflow version (GPU?): 2.9.1 (True)
- Flax version (CPU?/GPU?/TPU?): 0.5.2 (cpu)
- Jax version: 0.3.14
- JaxLib version: 0.3.14
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>


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

`pip uninstall timm`, and then:

```python
from transformers import AutoModel, AutoConfig

cfg = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-detr")
model = AutoModel.from_config(cfg)
```

raising:
```
Traceback (most recent call last):
  File "<tmp 1>", line 18, in <module>
    model = AutoModel.from_config(cfg)
  File "/home/fxmarty/hf_internship/transformers/src/transformers/models/auto/auto_factory.py", line 410, in from_config
    return model_class._from_config(config, **kwargs)
  File "/home/fxmarty/hf_internship/transformers/src/transformers/utils/import_utils.py", line 1008, in __getattribute__
    return super().__getattribute__(key)
AttributeError: type object 'DetrModel' has no attribute '_from_config'
```

### Expected behavior

It should raise:

```
ImportError: 
DetrModel requires the timm library but it was not found in your environment. You can install it with pip:
`pip install timm`. Please note that you may need to restart your runtime after installation.
```

as in https://github.com/huggingface/transformers/blob/main/src/transformers/utils/dummy_timm_and_vision_objects.py#L78
Indeed, I can see why and it's an easy fix. Will make a PR in a couple of hours!<|||||>Can you try the PR mentioned above?<|||||>Works well thanks for the fix!