ModernBertUnpaddedRotaryEmbedding __init__ error
Author: Darejkal
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.55.0
- Platform: Linux-6.6.56+-x86_64-with-glibc2.35
- Python version: 3.11.13
- Huggingface_hub version: 0.34.3
- Safetensors version: 0.5.3
- Accelerate version: 1.8.1
- Accelerate config: 	not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.6.0+cu124 (CUDA)
- Tensorflow version (GPU?): 2.18.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.10.6 (gpu)
- Jax version: 0.5.2
- JaxLib version: 0.5.1
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: Tesla P100-PCIE-16GB

### Who can help?

_No response_

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

Run

```
from transformers import ModernBertForSequenceClassification,ModernBertConfig
conf= ModernBertConfig(
**{
  "architectures": [
    "ModernBertForSequenceClassification"
  ],
  "attention_bias": False,
  "attention_dropout": 0.0,
  "classifier_activation": "gelu",
  "classifier_bias": False,
  "classifier_dropout": 0.0,
  "classifier_pooling": "mean",
  "cls_token_id": 50281,
  "decoder_bias": True,
  "deterministic_flash_attn": False,
  "embedding_dropout": 0.0,
  "eos_token_id": 50282,
  "global_attn_every_n_layers": 3,
  "global_rope_theta": 160000.0,
  "gradient_checkpointing": False,
  "hidden_activation": "gelu",
  "hidden_size": 768,
  "initializer_cutoff_factor": 2.0,
  "initializer_range": 0.02,
  "intermediate_size": 1152,
  "layer_norm_eps": 1e-05,
  "local_attention": 128,
  "local_rope_theta": 10000.0,
  "max_position_embeddings": 8192,
  "mlp_bias": False,
  "mlp_dropout": 0.0,
  "model_type": "modernbert",
  "norm_bias": False,
  "norm_eps": 1e-05,
  "num_attention_heads": 12,
  "num_hidden_layers": 22,
  "pad_token_id": 0,
  "position_embedding_type": "absolute",
  "tie_word_embeddings": True,
  "torch_dtype": "float32",
  "transformers_version": "4.47.0.dev0",
  "vocab_size": 4096
}
        )
model = ModernBertForSequenceClassification(conf)
```
Returns error:

```
/usr/local/lib/python3.11/dist-packages/transformers/models/modernbert/modeling_modernbert.py in __init__(self, config, layer_id)
    469             rope_theta = config.global_rope_theta
    470 
--> 471         if config._attn_implementation == "flash_attention_2":
    472             self.rotary_emb = ModernBertUnpaddedRotaryEmbedding(
    473                 dim=self.head_dim, max_seqlen=max_position_embeddings, base=rope_theta

/usr/local/lib/python3.11/dist-packages/transformers/models/modernbert/modeling_modernbert.py in __init__(self, dim, base, max_seqlen, device, dtype)
    155         """
    156         max_seqlen: if max_seqlen, device, and dtype are provided, we precompute the cos_sin_cache
--> 157             up to max_seqlen. If the max_seqlen, device, or dtype during training/inference differ,
    158             the cos_sin_cache will be recomputed during the forward pass.
    159         """
```

### Expected behavior

Model successfully initialized.

Comments: