AttributeError: 'MERTConfig' object has no attribute 'conv_pos_batch_norm'
Author: JacopoMadaluni
Pull request: no
Labels: name: bug

### System Info

```
- `transformers` version: 4.48.0
- Platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35
- Python version: 3.12.5
- Huggingface_hub version: 0.27.1
- Safetensors version: 0.5.2
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: no
- Using GPU in script?: yes (but makes no difference on cpu)
- GPU type: NVIDIA GeForce RTX 3090
```

### Who can help?

Hello everyone, since updating from `4.47.1` to version `4.48.0` we are unable to load `MERT-v1-330M` on the latest revision.
This works perfectly fine on the previous version.

I haven't seen any mention of a breaking change regarding this, have we missed something or is this a legitimate bug?

```
config.model = tr.AutoModel.from_pretrained(config.model_id, trust_remote_code=True).to(device)
.venv/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:559: in from_pretrained
    return model_class.from_pretrained(
.venv/lib/python3.12/site-packages/transformers/modeling_utils.py:4090: in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
../../.cache/huggingface/modules/transformers_modules/m-a-p/MERT-v1-330M/0e06c986db0527c0fd1b47181c40f006805e3de0/modeling_MERT.py:92: in __init__
    self.encoder = HubertEncoderStableLayerNorm(config)
.venv/lib/python3.12/site-packages/transformers/models/hubert/modeling_hubert.py:1023: in __init__
    self.pos_conv_embed = HubertPositionalConvEmbedding(config)
.venv/lib/python3.12/site-packages/transformers/models/hubert/modeling_hubert.py:275: in __init__
    if config.conv_pos_batch_norm:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = MERTConfig {
  "_attn_implementation_autoset": true,
  "_name_or_path": "m-a-p/MERT-v1-330M",
  "activation_dropout": ... "torch_dtype": "float32",
  "transformers_version": "4.48.0",
  "use_weighted_layer_sum": false,
  "vocab_size": 32
}
, key = 'conv_pos_batch_norm'

    def __getattribute__(self, key):
        if key != "attribute_map" and key in super().__getattribute__("attribute_map"):
            key = super().__getattribute__("attribute_map")[key]
>       return super().__getattribute__(key)
E       AttributeError: 'MERTConfig' object has no attribute 'conv_pos_batch_norm'

.venv/lib/python3.12/site-packages/transformers/configuration_utils.py:211: AttributeError
```

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

1. Import transformers (version 4.48.0) and load mert
```
import transformers as tr

m = tr.AutoModel.from_pretrained("m-a-p/MERT-v1-330M", trust_remote_code=True).to("cuda")

```

### Expected behavior

I should be able to load the model

Comments:
Hmm, it seems like the problem here is that the MERT model uses custom code, but imports from `HubertModel`. This means that changes to `HubertModel` have the potential to break MERT. In this case, the cause is https://github.com/huggingface/transformers/pull/34389.

This should be a relatively rare event, and the the simplest solution is to ask the MERT authors to add `conv_pos_batch_norm` to `MertConfig`, or to open a PR to add that. To avoid issues like this in future, you'd probably need to copy the relevant code into the MERT repository itself, so that MERT doesn't change when Hubert is updated in the base `transformers` library.

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.

I wouldn't want this to become stale, it can be quite annoying for a model definition to break depending on another one's config changes.


I've just run into this problem too

Unfortunately, we can't really fix this in Transformers! The update **has to be made in the MERT repo, by the MERT authors.** Please open an issue there and try to contact them!