RuntimeError: Failed to import transformers.generation.utils because of the following error (look up to see its traceback): cannot import name 'GenerateOutput' from partially initialized module 'transformers.generation.utils' (most likely due to a circular import)
Author: sysuls1
Pull request: no

### System Info

- `transformers` version: 4.40.2
- Platform: Linux-6.5.0-28-generic-x86_64-with-glibc2.35
- Python version: 3.10.14
- Huggingface_hub version: 0.20.3
- Safetensors version: 0.4.2
- Accelerate version: 0.30.1
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.1.2 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Traceback (most recent call last):
  File "/root/lspkg/profile.py", line 35, in <module>
    model = AutoModelForCausalLM.from_pretrained(
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 550, in from_pretrained
    model_class = get_class_from_dynamic_module(
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 489, in get_class_from_dynamic_module
    final_module = get_cached_module_file(
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 315, in get_cached_module_file
    modules_needed = check_imports(resolved_module_file)
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 175, in check_imports
    importlib.import_module(imp)
  File "/root/anaconda3/envs/qianwen/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers_stream_generator/__init__.py", line 1, in <module>
    from .main import init_stream_support
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers_stream_generator/main.py", line 1, in <module>
    from transformers import (
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1501, in __getattr__
    value = getattr(module, name)
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1500, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1512, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.generation.utils because of the following error (look up to see its traceback):
cannot import name 'GenerateOutput' from partially initialized module 'transformers.generation.utils' (most likely due to a circular import) (/root/anaconda3/envs/qianwen/lib/python3.10/site-packages/transformers/generation/utils.py)

### Expected behavior

尝试了不同版本的transformers，都是报同样的错误，transformers_stream_generator==0.0.4

Comments:
cc @gante @zucchini-nlp 

@sysuls1 hey! The reason might be in the way you name the python file. If it has the same name as the package you're trying to import, you have to rename it

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.