Inheritance issue with _LazyConfigMapping
### System Info

- `transformers` version: 4.30.2
- Platform: Linux-3.10.0-1160.90.1.el7.x86_64-x86_64-with-glibc2.17
- Python version: 3.10.11
- Huggingface_hub version: 0.16.2
- Safetensors version: 0.3.1
- PyTorch version (GPU?): 2.0.0.post200 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): 0.6.8 (gpu)
- Jax version: 0.4.8
- JaxLib version: 0.4.7

### Who can help?

@ArthurZucker
@Narsil

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

Not Applicable

### Expected behavior

`_LazyConfigMapping` and `_LazyLoadAllMappings` inherits from `OrderedDict`, but they do not use any feature of `OrderedDict`. 
It's probably a good idea to merge `self._mapping` into `self` so that the inheritance is meaningful. 
Hi, thank you for pointing out this.

Looks like you are right. However, this is just a simple utility to make things easier internally and there is no need to over-engineering😅<|||||>> Hi, thank you for pointing out this.
> 
> Looks like you are right. However, this is just a simple utility to make things easier internally and there is no need to over-engineering😅

Thank you for your quick reply. 

I noticed this I was trying to read the model list so that it will arise an error in case an invalid model name is specified. 
As it takes quite some time to set up the environment and build dataset before building model and raise error. 

I wonder if there are better ways to validate arguments before? reading `CONFIG_MAPPING_NAMES` is probably not an good idea as user may register their own model. 

Also, I noticed there are hundreds of lines in `CONFIG_MAPPING_NAMES`, which could be a bit redundant and has to be modified manually when new algorithms are added. May I try to add some code to find them and construct `CONFIG_MAPPING_NAMES` automatically? <|||||>Hello!

> I wonder if there are better ways to validate arguments before?

It's not clear to me what's your use case here. If you specify  invalid model name, an error must be given. Do you mean a better error message instead of just a simple key error?


> Also, I noticed there are hundreds of lines in CONFIG_MAPPING_NAMES, which could be a bit redundant and has to be modified manually when new algorithms are added.

It's actually not edited that frequently 😅 . No need to over engineering in this case (but see below comments too)

>  May I try to add some code to find them and construct CONFIG_MAPPING_NAMES automatically?

This list should be very explicit so we know what model types (config) are available in `transformers`. Of course we can try to detect the modules (or easier check the python files), but that could potentially gives wrong results too (and in that case, difficult to reason/figure out).

<|||||>> It's not clear to me what's your use case here. If you specify invalid model name, an error must be given. Do you mean a better error message instead of just a simple key error?

Our model needs some information from dataset to build, so we can only build model after built dataset.

```python
dataset = Dataset(*args, **kwargs)
model = Model(pretrained=xxx, num_outputs=dataset.num_outputs)
```

For some tasks, it takes hours to build a dataset. And hence take hours to fail. So, it's better to validate model before building.

```python
if xxx not in XXX_LIST:
    raise RuntimeError("Invalid model specified.")
dataset = Dataset(*args, **kwargs)
model = Model(pretrained=xxx, num_outputs=dataset.num_outputs)
```<|||||>Hi!

We need more specific info of the failing you encounter.

I assume you are saying 

```
model = some_hf_model_class.from_pretrained(pretrained_model_name_or_path="xxx")
```
where `xxx` is a a model repo name on the Hub (or a local path).

In your example, you are passing a model type name ``CONFIG_MAPPING_NAMES .

However, if `Model` is **your custom class** which can be initialized with a model type name, then you have to implement the argument check in your own codebase.