noamaanMulla-03/transformers-issues huggingface dataset:
Fix Tensor + Embedding error in some cases when using SiglipVisionModel
Author: kaitolucifer
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.
-->

<!-- Remove if not applicable -->

Fixes #33993

<!-- 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

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:
🤗
Cache: revert DynamicCache init for BC
Author: gante
Pull request: yes

# What does this PR do?

Reverts the optional argument in `DynamicCache.__init__`, which broke BC in a few edge cases.

The optional argument was needed in `mllama` because the model skips layers. The original solution was to initialize empty lists on all layers, with the number of layers being an input argument.

This PR removes the optional argument, but adds the ability to handle skipped layers on `DynamicCache`.

EDIT: fixes #33794 

_________________________________________________

✅ same tests are passing as in `main` (there are a couple of slow tests failing!)

Comments:
Hey! 🤗 Thanks for your contribution to the `transformers` library!

Before merging this pull request, slow tests CI should be triggered. To enable this:
- Add the `run-slow` label to the PR
- When your PR is ready for merge and all reviewers' comments have been addressed, push an empty commit with the command `[run-slow]` followed by a comma separated list of all the models to be tested, i.e. `[run_slow] model_to_test_1, model_to_test_2`
  - If the pull request affects a lot of models, put at most 10 models in the commit message
- A `transformers` maintainer will then approve the workflow to start the tests

(For maintainers) The documentation for slow tests CI on PRs is [here](https://www.notion.so/huggingface2/CI-for-pull-requests-8335bd9217d24d1e8ed1d3a016f39804).

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

(rebased to include a flaky test fix)
[Docs] Add Developer Guide: How to Hack Any Transformers Model
Author: MagnusS0
Pull request: yes

# What does this PR do?

This PR adds a new developer guide titled "How to Hack Any Transformers Model" to the docs. The guide shows how to modify existing models, using the Segment Anything Model (SAM) as an example. It also encourages community contributions by inviting others to share their own hacks.

## Changes

- Added a new developer guide at `docs/source/en/how_to_hack_models.md`
- Updated `docs/source/en/_toctree.yml` to include the new guide in the Developer Guides section.


Fixes #33928

## Before submitting

- [x] This PR improves the docs.
- [x] I have read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request).
- [x] This was discussed  in the GitHub issue #33928.

## Who can review?

Tagging @ArthurZucker as we discussed this in issue #33928 and the code example was provided by him. Let me know if this is what you had in mind 🤗 

Comments:
Ahh, yeah makes sense, then I can extend the example and show how it also can be used e.g.  with PEFT! WDYT?

Of course! And if people have example of adding SDPA for example (not here for SAM) or good hacking, will go there! let's call for contribution probably! 🤗 

**Updated the PR:** It now adds a new developer guide titled "How to Hack Any Transformers Model" 🚀
I've also updated the PR description and title accordingly.

Let me know your thoughts! Do you think we should make the guide more general regarding model hacking? Or do you (or anyone else) have any extra examples to add?


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

Thanks @MagnusS0 🤗 

Thanks to you as well @ArthurZucker ! Didn't know about pre hooks so super helpful 🤗
[`pytes collection`] Fix flax test collection
Author: ArthurZucker
Pull request: yes

# What does this PR do?
` RUN_SLOW=1 pytest  -n 4 tests/models/*/test_modeling_* -k test_inference_interpolate_pos_encoding -vvv -s` would not work without this 

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

I have absolutely no idea
[Bug] Error when saving NVLM model
Author: mgoin
Pull request: no
Labels: name: bug

### System Info

```
- `transformers` version: 4.45.1
- Platform: Linux-6.5.0-35-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.23.5
- Safetensors version: 0.4.3
- Accelerate version: 0.34.2
- Accelerate config:    not found
- PyTorch version (GPU?): 2.4.0+cu121 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: Just using `device_map="auto"`
- Using GPU in script?: H100
- GPU type: NVIDIA H100 80GB HBM3
```

### 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

The error is due to an undefined variable:
```
  File "/home/mgoin/venvs/test/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2616, in save_pretrained
    misplaced_generation_parameters = model_to_save.config._get_non_default_generation_parameters()
  File "/home/mgoin/venvs/test/lib/python3.10/site-packages/transformers/configuration_utils.py", line 1050, in _get_non_default_generation_parameters
    if default_config is not None:
UnboundLocalError: local variable 'default_config' referenced before assignment
```

Looking at where that variable would be assigned, there is a case where decoder_config is set to None, but not default_config
```python
        # Composite models don't have a default config, use their decoder config as a fallback for default values
        # If no known pattern is matched, then `default_config = None` -> check against the global generation defaults
        try:
            default_config = self.__class__()
        except ValueError:
            decoder_config = self.get_text_config(decoder=True)
            if decoder_config is not self:
                default_config = decoder_config.__class__()
            else:
                decoder_config = None
```

### Expected behavior

Saving the model should not result in a crash

Comments:
Thanks for reporting!
Pytest on PRs
Author: ArthurZucker
Pull request: yes

# What does this PR do?
try to support comments to trigger slow runs and also custom tests

Comments:
/run-tests pytest tests/models/test_modeling_t5

/pytest tests/models/test_modeling_t5

/pytest tests/models/test_modeling_t5

/pytest tests/models/test_modeling_t5


/test

I keep commenting

/test

/pytest /support /test /action

/testing

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

/pytest

/pytest

This comment contains /pytest, running the specified job...

/pytest


This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

/pytest
🌐 [i18n-KO] Translated `gguf.md` to Korean
Author: yijun-lee
Pull request: yes

# What does this PR do?

Translated the `gguf.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@jungnerd, @cjfghk5697, @yijun-lee, @mreraser


## 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33764). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `swinv2.md` to Korean
Author: mreraser
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `swinv2.md` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [x] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@yijun-lee, @mreraser, @jungnerd, @cjfghk5697
<!-- @win2dvp21, @enchantee00, @fabxoe, @1kmmk1, @junejae -->
<!-- @SeungAhSon, @Jwaminju, @thsamajiki, @4N3MONE, @jungnerd -->
<!-- @mjk0618, @cjfghk5697, @ahnjj, @JinukHong, @nuatmochoi -->
<!-- @010kim, @chhaewxn, @boyunJang, @jeongiin, @harheem -->

## Before submitting
- [x] 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#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.
- [x] 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? (Final)
Hello @stevhliu !  May you please review this PR? Thank you! 

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
<!--
Hello @stevhliu !  May you please review this PR? Thank you! 

Have a nice day :)
-->

Comments:
@mreraser LGTM!

LGTM!

Thank you for your review! 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33566). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `audio_utils.md` to Korean
Author: yijun-lee
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `audio_utils.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `audio_utils.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@jungnerd, @cjfghk5697, @yijun-lee, @mreraser


## 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
LGTM 💯 

LGTM:🎉

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33802). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `esm.md` to Korean
Author: yijun-lee
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `esm.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@jungnerd, @cjfghk5697, @yijun-lee, @mreraser


## 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
LGTM 🚀 

LGTM🤗

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33796). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `time_series_utils.md` to Korean
Author: yijun-lee
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `time_series_utils.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@jungnerd, @cjfghk5697, @yijun-lee, @mreraser


## 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
LGTM 💯 

LGTM😺

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33806). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `pipelines_utils.md` to Korean
Author: yijun-lee
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `pipelines_utils.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `pipelines_utils.md` file of the documentation to Korean.
Thank you in advance for your review.

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
May you please review this PR?
@jungnerd, @cjfghk5697, @yijun-lee, @mreraser


## 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
LGTM 💯 

LGTM😏

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