`compute_transition_scores` fails for vision-language models
Author: kurzdev
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.48.3
- Platform: Linux-4.18.0-513.5.1.el8_9.x86_64-x86_64-with-glibc2.35
- Python version: 3.11.11
- Huggingface_hub version: 0.30.2
- Safetensors version: 0.5.3
- Accelerate version: 1.6.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.6.0+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?: yes, across 4 GPUs with `accelerate launch --multi-gpu`
- Using GPU in script?: yes
- GPU type: NVIDIA A100-SXM4-80GB

### Who can help?

@zucchini-nlp @gante 

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

```py
import torch
from torch.utils.data import DataLoader
from transformers import AutoProcessor, LlavaNextForConditionalGeneration


BATCH_SIZE = 4
NUM_BEAMS = 5

model = LlavaNextForConditionalGeneration.from_pretrained(
    "llava-hf/llama3-llava-next-8b-hf",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    attn_implementation="flash_attention_2",
)
processor = AutoProcessor.from_pretrained(
    "llava-hf/llama3-llava-next-8b-hf",
    model_max_length=4096,  # https://llava-vl.github.io/blog/2024-04-30-llava-next-video/
)

dataset = ...  # Some custom VQAv2 dataset
loader = DataLoader(
    dataset,
    batch_size=BATCH_SIZE,
    num_workers=2,
    pin_memory=True,
    shuffle=False,
)

for batch in loader:
    features = processor(
        images=batch["image"],
        text=batch["prompt"],
        return_tensors="pt",
        padding="max_length",
        truncation=True
    )

    outputs = model.generate(
        max_new_tokens=128,
        num_beams=NUM_BEAMS,
        length_penalty=0,
        input_ids=features["input_ids"],
        attention_mask=features["attention_mask"],
        pixel_values=features["pixel_values"],
        image_sizes=features["image_sizes"]
        pad_token_id=processor.tokenizer.eos_token_id,
        return_dict_in_generate=True,
        output_logits=True,
        output_scores=True
    )

    transition_scores = model.compute_transition_scores(
        outputs.sequences,
        outputs.scores,
        outputs.beam_scores,
        normalize_logits=True,
    )
```

The above code will fail because the config for vision-language models has no attribute named `vocab_size` (accessed [here](https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L1415) and [here](https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L1429)):
```py
...
File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/pk65sity/kavqa/.venv/lib/python3.11/site-packages/transformers/generation/utils.py", line 1254, in compute_transition_scores
    scores = scores.reshape(-1, self.config.vocab_size, scores.shape[-1])
                                ^^^^^^^^^^^^^^^^^^^^^^
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/pk65sity/kavqa/.venv/lib/python3.11/site-packages/transformers/configuration_utils.py", line 211, in __getattribute__
    return super().__getattribute__(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'LlavaNextConfig' object has no attribute 'vocab_size'
```

### Expected behavior

I'd expect the function to recognise the presence of a vision-language model and choose the right config entry.
I'd assume that this can probably be fixed with a simple `vocab_size = self.text_config.vocab_size if hasattr(self, "text_config") else self.config.vocab_size`?

Let me know if I'm missing anything, otherwise I can also draft a PR. 😊

Comments:
Oh, that was not adapted for multimodal models apparently. It should be looking in `self.config.get_text_config()`. Yeah, feel free to submit a PR if you want to :)