noamaanMulla-03/transformers-issues huggingface dataset:
Unhandled 'num_items_in_batch' in Mistral model
Author: gheinrich
Pull request: no
Labels: name: bug

### System Info

- Transformer version: 4.46.0
- Model: nvidia/Mistral-NeMo-Minitron-8B-Base

### Who can help?

_No response_

### 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

When calling the forward method on the NeMo Mistral model, the following exception occurs:

```
[rank2]:   File "/lustre/fsw/portfolios/llmservice/users/gheinrich/anaconda3/envs/vila/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1582, in _call_impl
[rank2]:     result = forward_call(*args, **kwargs)
[rank2]: TypeError: MistralForCausalLM.forward() got an unexpected keyword argument 'num_items_in_batch'
```

### Expected behavior

The forward() method should use `num_items_in_batch` for the loss calculation.

Comments:
and careful here, not to break multi gpu... With Llama 3.1 I get usually an error when dividing loss/num_items_in_batch, they tend to go to different gpus.

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.
[docs] Reorganize Performance and scalability section
Author: stevhliu
Pull request: yes

This PR reorganizes the Performance and scalability section into two topics, inference and training, to improve navigation. Other changes include:

- move hyperparameter search to the Trainer developer guide (the `hpo_train.md` doc should redirect to `trainer.md` now)
- move "custom hardware for training" to the conceptual guides since it is more about hardware building
- collapse the "main classes" and "internal helpers" API sections

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_30944). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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.
[i18n-ar] Translated file: `docs/source/ar/tasks/summarization.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/tasks/summarization.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/) ?Please add a link to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

### Who can review?
@stevhliu , @MKhalusova , @abodacs, may you please review this PR?



Comments:
Thank you @abodacs
[i18n-ar] Translated file: `docs/source/ar/tasks/translation.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/tasks/translation.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/) ?Please add a link to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

### Who can review?
@stevhliu , @MKhalusova , @abodacs, may you please review this PR?



Comments:
Fix for compile: use call instead of forward
Author: SilverSoldier
Pull request: yes

# What does this PR do?

Use model's `__call__` instead of `forward` directly to be able to work with torch compile used in the form of `model.compile`.

Able to see runtime drop for llama 7b without and with this change (1336 to 1017 seconds) and compile time increase (_compile.compile_inner: 10.2451 to 54.6842 seconds probably due to recompiles)

Fixes #34906

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @ylacombe, @eustlb
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc @MekkCyber

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
It's in the generation code so cc @gante
Reintroduce Python 3.9 support for ModernBERT
Author: tomaarsen
Pull request: yes

# What does this PR do?

Fixes https://huggingface.co/answerdotai/ModernBERT-base/discussions/21

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Reproduction
```python
from typing import Tuple

foo: Tuple[int] | Tuple[str]
```
This script fails in Python 3.9:
```
Traceback (most recent call last):
  File "[sic]/demo_py39_test.py", line 4, in <module>
    foo: Tuple[int] | Tuple[str]
TypeError: unsupported operand type(s) for |: '_GenericAlias' and '_GenericAlias'
```

But works in Python 3.10+. See also https://bugs.python.org/issue42233

## After this PR
With this PR in place, ModernBERT can be ran in Python 3.9.

## Who can review?

@ArthurZucker
cc @warner-benjamin @KoichiYasuoka

- Tom Aarsen

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35458). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix new BNB test failures
Author: matthewdouglas
Pull request: yes
Labels: name: Quantization

# What does this PR do?

Fixes test failures on T4 runners as a result of merging #34713.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case. ([Slack thread](https://huggingface.slack.com/archives/C01NE71C4F7/p1734464357810819))
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?
@LysandreJik

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35345). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

cc @jiqing-feng as well

Thanks for your fix!
Fix paligemma warning message
Author: hiyouga
Pull request: yes

# What does this PR do?

Fixes https://github.com/hiyouga/LLaMA-Factory/issues/6499

The `logger.warning_once` method only accepts one argument, so we remove the comma.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?

@zucchini-nlp 


Comments:
Fix: Correct logger formate issues in Paligemma model.
Author: marko1616
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Description
The `logger.warning_once` function, if given two arguments, will interpret the first argument as a format string and the second as its arguments. To prevent this unintended string formatting, we use string literal concatenation to pass a single string argument. See [python docs](https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation) and [other code](https://github.com/huggingface/transformers/blob/919220dab1e29f4d04eacd61a197a45a4fec2613/src/transformers/models/llava/processing_llava.py#L172).
Any way this message also need a change here because the current verison is `4.47.1` now.

## Who can review?
@amyeroberts
@qubvel

## Thanks to those who review this PR.

Comments:
Fixed at #35486
tokenizers v0.21 isn't supported
Author: gremlation
Pull request: no
Labels: name: Feature request

### Feature request

[tokenizers v0.21.0](https://github.com/huggingface/tokenizers/releases/tag/v0.21.0) was released in November. There are no listed breaking changes.

### Motivation

Other packages conflict with `transformers` requirement of v0.20.x only.

### Your contribution

Why is this a required field? If I'm going to open a PR, I'm going to do it *after* I file the issue so that the Git commit can mark it as fixed.

Comments:
Wav2Vec2BertForSequenceClassification   freeze_feature_encoder() doesn't exist
Author: HERIUN
Pull request: no
Labels: name: Feature request

### Feature request


```
model = AutoModelForAudioClassification.from_pretrained("facebook/w2v-bert-2.0")

model.freeze_feature_encoder() ## doesn't exist!!
```

Is it missed? 

### Motivation

another classification model has ```freeze_feature_encoder()```

### Your contribution

None

Comments:
freeze_base_model() exists..
Add support for Aria model
Author: fakerybakery
Pull request: no
Labels: name: New model

name: Feature request

name: Multimodal

### Feature request

Hi,
Would it be possible to add support for the [Aria model](https://huggingface.co/rhymes-ai/Aria)?
Thanks!

### Motivation

Aria is not supported without custom code

### Your contribution

N/A

Comments:
cc @aymeric-roucher who I believe is working on it right now :)

Yes I'm working on it at the moment! https://github.com/huggingface/transformers/pull/34157

PR is merged let's close this!
Add MLLama
Author: ArthurZucker
Pull request: yes
Labels: name: New model

# What does this PR do?
Adds model

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33703). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Nice work. Is the `MllamaVisionModel` introduced here completely running on CPU device?

Yes, it can run on CPU
Fix typo is_soundfile_availble 
Author: j0yk1ll
Pull request: no
Labels: name: Feature request

### Feature request

Please fix the typo in transformers.utils

is_soundfile_availble should be is_soundfile_available

### Motivation

Should be self explanatory

### Your contribution

There already is a PR but it hasn't been merged for multiple months even though this fix takes 1 minute. 

https://github.com/huggingface/transformers/pull/35030

Comments:
We just merged the other PR, thank you!
[Feature Request] Add beam search text streaming visualization feature
Author: MosheOfer1
Pull request: no
Labels: name: Feature request

### Feature request

### Feature request
Remove the limitation that prevents using streamers with beam search. Currently, there's an error in the generation code:

```python
if streamer is not None and (generation_config.num_beams > 1):
   raise ValueError(
       "`streamer` cannot be used with beam search (yet!). Make sure that `num_beams` is set to 1."
   )

### Motivation

### Motivation
When working with beam search generation, it's often difficult to understand why the model makes certain choices or how the beams evolve during generation. While debugging some beam search behavior, I discovered the `MultiBeamTextStreamer` class, but it took me some time to find it as it wasn't prominently featured in the documentation.

From an educational perspective, this tool is extremely valuable. Being able to visualize multiple beams in real-time provides an excellent way to teach and understand how beam search actually works. Students and educators could see the algorithm's decision-making process step by step, making abstract concepts concrete and interactive.

Making this feature more visible and providing better examples would help users who need to:
- Learn/teach beam search concepts interactively
- Debug beam search issues
- Understand model decision-making
- Create interactive demos

This improvement would make beam search less of a "black box" and provide a powerful educational tool for the NLP community.

### Your contribution

### Your contribution
I have implemented the MultiBeamTextStreamer class with tests and documentation. I plan to submit a PR for review after final cleanup. Would love early feedback on this approach.

Example of usage:
https://huggingface.co/spaces/mosheofer1/multi_beam_text_streamer

Comments:
cc @gante @zucchini-nlp
Bug for logger.warning_once
Author: Snowdar
Pull request: no
Labels: name: bug

https://github.com/huggingface/transformers/blob/5523e38b553ff6c46b04d2376870fcd842feeecc/src/transformers/generation/configuration_utils.py#L765

The UserWarning could not be loggered by logging and here is a simple test:
```
>>> from transformers.generation.configuration_utils import logger
>>> logger.warning_once('error', UserWarning)
--- Logging error ---
Traceback (most recent call last):
  File "/home/test/miniconda3/envs/test/lib/python3.11/logging/__init__.py", line 1110, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/test/miniconda3/envs/test/lib/python3.11/logging/__init__.py", line 953, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/home/testminiconda3/envs/test/lib/python3.11/logging/__init__.py", line 687, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/home/test/miniconda3/envs/test/lib/python3.11/logging/__init__.py", line 377, in getMessage
    msg = msg % self.args
          ~~~~^~~~~~~~~~~
TypeError: not all arguments converted during string formatting
Call stack:
  File "<stdin>", line 1, in <module>
  File "/home/test/miniconda3/envs/test/lib/python3.11/site-packages/transformers/utils/logging.py", line 328, in warning_once
    self.warning(*args, **kwargs)
Message: 'error'
Arguments: (<class 'UserWarning'>,)
```

Comments:
Seems legit, so thank you for the bug report! Would you be willing to open a PR to fix that line?

Hi @Rocketknight1 , I took a look at this and it seems like a usage error. 

`msg % self.args` is always going to fail if `self.args` doesn't have the same number of elements as there are format specifiers in the the first argument (in this case 0, not equal to the one argument supplied - the class `UserWarning`).

If I am misunderstanding, can you please let me know what you would expect the log/warning to look like given @Snowdar's inputs? Then I will adjust my test case and submit a fix/PR.

Hi @secrettoad, I think the problem is simply that passing `UserWarning` into `warning_once` isn't supported - if that extra arg is removed, everything should work.

Okay great. Thank you.

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.
Applies the rest of the init refactor except to modular files
Author: LysandreJik
Pull request: yes

I'm sorry @ArthurZucker 

Comments:
This needs #35364 to be merged

cc @LysandreJik test all works you can check the errors now! 🤗 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35238). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.