Qwen Audio DisjunctiveConstraint missing
Author: Znerual
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.57.0.dev0
- Platform: Linux-6.14.0-33-generic-x86_64-with-glibc2.39
- Python version: 3.12.11
- Huggingface_hub version: 1.0.0.rc5
- Safetensors version: 0.6.2
- Accelerate version: 1.10.1
- Accelerate config:    not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.8.0+cu128 (CUDA)
- Using distributed or parallel set-up in script?: no
- Using GPU in script?: yes
- GPU type: NVIDIA RTX PRO 2000 Blackwell Generation Laptop GPU

### Who can help?

@eustlb @ebezzam @vasqu

### Information

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

### Tasks

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

### Reproduction

Take the example code from the website:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation import GenerationConfig
import torch
torch.manual_seed(1234)

tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-Audio", trust_remote_code=True)

# use bf16
# model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-Audio", device_map="auto", trust_remote_code=True, bf16=True).eval()
# use fp16
# model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-Audio", device_map="auto", trust_remote_code=True, fp16=True).eval()
# use cpu only
# model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-Audio", device_map="cpu", trust_remote_code=True).eval()
# use cuda device
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-Audio", device_map="cuda", trust_remote_code=True).eval()

# Specify hyperparameters for generation (No need to do this if you are using transformers>4.32.0)
# model.generation_config = GenerationConfig.from_pretrained("Qwen/Qwen-Audio", trust_remote_code=True)
audio_url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/1272-128104-0000.flac"
sp_prompt = "





"
query = f"<audio>{audio_url}</audio>{sp_prompt}"
audio_info = tokenizer.process_audio(query)
inputs = tokenizer(query, return_tensors='pt', audio_info=audio_info)
inputs = inputs.to(model.device)
pred = model.generate(**inputs, audio_info=audio_info)
response = tokenizer.decode(pred.cpu()[0], skip_special_tokens=False,audio_info=audio_info)
print(response)
# <audio>https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/1272-128104-0000.flac</audio>





mister quilting is the apostle of the middle classes and we are glad to welcome his gospel


```

results in the error:

```
tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 211/211 [00:00<00:00, 753kB/s]
tokenization_qwen.py: 22.8kB [00:00, 32.0MB/s]
audio.py: 15.0kB [00:00, 16.0MB/s]
A new version of the following files was downloaded from https://huggingface.co/Qwen/Qwen-Audio:
- audio.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
A new version of the following files was downloaded from https://huggingface.co/Qwen/Qwen-Audio:
- tokenization_qwen.py
- audio.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
qwen.tiktoken: 2.56MB [00:00, 52.5MB/s]
special_tokens_map.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.00/3.00 [00:00<00:00, 8.41kB/s]
audio_start_id: 155163, audio_end_id: 155164, audio_pad_id: 151851.
config.json: 1.26kB [00:00, 2.82MB/s]
configuration_qwen.py: 2.35kB [00:00, 5.27MB/s]
A new version of the following files was downloaded from https://huggingface.co/Qwen/Qwen-Audio:
- configuration_qwen.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
modeling_qwen.py: 58.3kB [00:00, 59.1MB/s]
Encountered exception while importing transformers_stream_generator: cannot import name 'DisjunctiveConstraint' from 'transformers' (/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/__init__.py)
Traceback (most recent call last):
  File "/home/ruzickal/Code/entity-analyzer-backend/audio-llm-api/test_qwen_audio.py", line 15, in <module>
    model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-Audio", device_map="cuda", trust_remote_code=True).eval()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/models/auto/auto_factory.py", line 367, in from_pretrained
    model_class = get_class_from_dynamic_module(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/dynamic_module_utils.py", line 594, in get_class_from_dynamic_module
    final_module = get_cached_module_file(
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/dynamic_module_utils.py", line 422, in get_cached_module_file
    modules_needed = check_imports(resolved_module_file)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/dynamic_module_utils.py", line 248, in check_imports
    importlib.import_module(imp)
  File "/home/ruzickal/.pyenv/versions/3.12.11/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/ruzickal/.cache/pypoetry/virtualenvs/audio-llm-api-nPR59pGu-py3.12/lib/python3.12/site-packages/transformers_stream_generator/__init__.py", line 1, in <module>
    from .main import init_stream_support
  File "/home/ruzickal/.cache/pypoetry/virtualenvs/audio-llm-api-nPR59pGu-py3.12/lib/python3.12/site-packages/transformers_stream_generator/main.py", line 1, in <module>
    from transformers import (
ImportError: cannot import name 'DisjunctiveConstraint' from 'transformers' (/home/ruzickal/Code/entity-analyzer-backend/transformers/src/transformers/__init__.py)
```

### Expected behavior

Run the example code  without an error

Comments:
Hey @Znerual,
it seems like this is remote code and dependent on third party libraries we don't maintain. The issue stems from the 3rd party library using features that are no longer supported (or the path changed). I suggest either
- downgrading the version compatible with the remote code
- submitting an issue/PR to the [remote code maintainers](https://huggingface.co/Qwen/Qwen-Audio) / the [3rd party library](https://github.com/LowinLi/transformers-stream-generator)

cc @gante for generation just in case

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.