Cannot import 'GenerationOutput' in 4.48.1
Author: inthree3
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.48.1
- Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.31
- Python version: 3.9.5
- Huggingface_hub version: 0.28.0
- 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?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA GeForce MX450

### Who can help?

@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
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationOutput
import torch

# Load model and tokenizer
model_name = "gpt2"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Encode input text
input_text = "Hello, how are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

# Generate text (Return logits)
output = model.generate(
    input_ids,
    return_dict_in_generate=True, 
    output_scores=True,           
    return_logits=True            
)

# Check if the output type is GenerationOutput
print(isinstance(output, GenerationOutput))  # True
```

### Expected behavior

The code above should run without any errors.

Comments:
Hi @inthree3 

Try the following script
```py
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load model and tokenizer
model_name = "gpt2"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Encode input text
input_text = "Hello, how are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

# Generate text (Return logits)
output = model.generate(
    input_ids,
    return_dict_in_generate=True,
    output_scores=True,
    output_logits=True
)

# Check if the output type is GenerationOutput
print(type(output))
```

I understand your intention, so I won’t import the GenerationOutput class.

However, I would appreciate it if you could provide more explanation on why this method was not included in the documentation. Also, do you have any plans to reintroduce this class into the transformers library in the future?

Sincerely, big thanks for your quick response! 👍👍👍

The output classes aren't under `transformers` but under `transformers.generation.utils` so you can import them by `from transformers.generation.utils import xxx`. Also there isn't (and seems has never been) a `GenerationOutput` class but only dedicated output classes for decoder and encoder-decoder.

In this case `from transformers.generation.utils import GenerateDecoderOnlyOutput` should be the way to go.

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.