4.37 ImportError: cannot import name 'SampleOutput' from 'transformers.generation.utils'
Author: erew123
Pull request: no

### System Info

I am a developer of AllTalk https://github.com/erew123/alltalk_tts/ which uses the Coqui TTS engine https://github.com/coqui-ai/TTS

As of the 4.37 update, I have users reporting this error:
```
Traceback (most recent call last):
File "/home/ai/alltalk_tts/tts_server.py", line 7, in
from TTS.tts.configs.xtts_config import XttsConfig
File "/home/ai/alltalk_tts/alltalk_environment/env/lib/python3.11/site-packages/TTS/tts/configs/xtts_config.py", line 5, in
from TTS.tts.models.xtts import XttsArgs, XttsAudioConfig
File "/home/ai/alltalk_tts/alltalk_environment/env/lib/python3.11/site-packages/TTS/tts/models/xtts.py", line 12, in
from TTS.tts.layers.xtts.stream_generator import init_stream_support
File "/home/ai/alltalk_tts/alltalk_environment/env/lib/python3.11/site-packages/TTS/tts/layers/xtts/stream_generator.py", line 24, in
from transformers.generation.utils import GenerateOutput, SampleOutput, logger
ImportError: cannot import name 'SampleOutput' from 'transformers.generation.utils' (/home/ai/alltalk_tts/alltalk_environment/env/lib/python3.11/site-packages/transformers/generation/utils.py)
```

The issue is mainly this:

`ImportError: cannot import name 'SampleOutput' from 'transformers.generation.utils'`

Downgrading to 4.36.2 of Transformers makes things work fine again. 

I looked to see if this could be related to **Remove support for torch 1.10** but can find no references to **SampleOutput** being a part of that. 

Would you be able to confirm to me is this something that has been dropped in 4.37 or perhaps an omission that will be resolved in a future update? 

Thanks


### Who can help?

@sanchit-gandhi (Im guessing you may be the correct person as this is Speech, apologies if not).

### Information

- [X] The official example scripts
- [ ] 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

Use transformers 4.37 with the Coqui TTS engine and try to import their XTTS model.

### Expected behavior

Of course, for this model to import correctly. 

Comments:
cc @gante 


Just encountered this error and found this thread by google searching it

Confirm this happens on 4.37.0

Me too, literally just happened. I'll try downgrading first.

Encountered this error as well. Downgrading Transformers to 4.36.2 fixes it.

This worked for me:
Update your TTS requirements.txt look for transformers>=4.33.0 and replace it with:
transformers==4.33.0

Run:
pip install -r requirements.txt

@gante This seems to be due to `SampleOutput` being remove from `generation.utils.py` in #28494. I missed in the PR that the mapping were completely removed. I think the best thing to do is add back, with a patch and deprecation warning. 

> This worked for me: Update your TTS requirements.txt look for transformers>=4.33.0 and replace it with: transformers==4.33.0
> 
> Run: pip install -r requirements.txt

For anyone currently experiencing this issue - any version of transformers before 4.37 should still be fine i.e. setting `transformers>=4.33.0,<4.37` in requirements.txt should work until a patch is released. 

@amyeroberts Thanks for looking into this Amy & @gante its very appreciated!

transformers==4.33.0 works for me. 

transformers will import transformers_stream_generator, while transformers_stream_generator has the following import

```
from transformers.generation.utils import GenerateOutput, SampleOutput, logger
```
But in transformers>=4.37, SampleOutput was removed and transformers will raise ImportError although transformers_stream_generator has already been installed.
```
ImportError: This modeling file requires the following packages that were not found in your environment: transformers_stream_generator. Run pip install transformers_stream_generator
```

Hi all, a patch has been released which should resolve the issues here: `SampleOutput` can now be imported again as a type: https://github.com/huggingface/transformers/releases/tag/v4.37.1

You should be able to revert back to the original requirements.txt file, install the latest transformers and run your code with Coqui's TTS. 

@amyeroberts Thanks so much Amy. I will give it a test at some point soon and feed back if there's any issues. Really appreciate your help with that.

@amyeroberts Actually managed to give it a quick go now and everything loads up fine again! Awesome stuff! Ill close off the ticket. Again, thanks so much!

@erew123 Great - thanks for confirming!