Support Streaming to Other Locations Besides STDOUT
### Feature request

I would like to build a token streaming model that sends the tokens to a web socket or SSE connection. Today I would need to put a redirect from stdout to the other location which is a pain. Instead I would like to receive a raw python generator from the TextStreamer object that I can iterate over in any way I need.

### Motivation

I'd like to emulate something like https://github.com/hyperonym/basaran but in native HF code.

### Your contribution

TBD
cc @gante <|||||>@sam-h-bean an iterator class was merged yesterday, but I haven't communicated about it :)

You can check its implementation [here](https://github.com/huggingface/transformers/blob/fc5b7419d4c8121d8f1fa915504bcc353422559e/src/transformers/generation/streamers.py#L125). This would be what you are looking for, correct?

EDIT: communicated [here](https://twitter.com/joao_gante/status/1643330507093196800)<|||||>@gante Is there going to be an option for using this with the pipelines API? I would like to incorporate this feature into langchain but that currently only supports the pipeline API.<|||||>@sam-h-bean yes, it is in the works! :D <|||||>@gante What about dynamic batching combined with streaming? If I wanted to support dynamic batching for an LLM because I expected a high amount of throughput but I wanted to stream tokens back to each client individually how would I accomplish that?<|||||>@sam-h-bean for now only the [text-generation-inference](https://github.com/huggingface/text-generation-inference) supports it. 

I'd like to add it to `transformers` sometime in the future, but it definitely won't happen in the next months.<|||||>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.