noamaanMulla-03/transformers-issues huggingface dataset:
Fix docstring and type hint for resize
Author: daniilgaltsev
Pull request: yes

# What does this PR do?

Updates the type hint and the docstring for `resize` since the image transformation functions should work with numpy arrays.

Closes #26986 


## 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?
- [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.

@rafaelpadilla



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_27104). All of your documentation changes will be reflected on that endpoint.
Why not use model_wrapped in trainer evaluation_loop?
Author: tangzhiyi11
Pull request: no

### System Info

Transformers >= 4.30.2.

### Who can help?

@muellerzr @pacman100 

### 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

Why not use model_wrapped in trainer evaluation_loop?

![image](https://github.com/huggingface/transformers/assets/5955111/9aae5ff8-51d8-4953-ab1c-7b0e27af64d0)

### Expected behavior


like #26281 

Comments:
correcting the ping to @pacman100 😉 

> correcting the ping to @pacman100 😉

thanks, i fix 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.
Fix wrong vocab_size updating when calling `resize_token_embeddings` on an uninitialized model
Author: Jingru
Pull request: yes

# What does this PR do?

`resize_token_embeddings` intends to update model vocab_size to the size of the first dimension of the newly-built embedding's weight.

However, if this method is call on an uninitialized model (e.g.: in `no_init_weight` context) and the parameter `new_num_tokens` equals to the old vocab_size, the internal function `_resize_token_embeddings` will return the old embedding directly whose weight is not initialized.

In this scenario, the model's vocab_size will be set to 0 which is unexpected.


## Who can review?

@ArthurZucker and @younesbelkada



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_26264). All of your documentation changes will be reflected on that endpoint.

Hey 👋🏻 I am not entirely sure I understand the use case here. Could you share a reproducing snippet? 

Sorry for the missing information: this issue is found when deepspeed zero3 is enabled, which disables init_weight action.

I'm noticing that `_get_resized_embeddings` function has already modified in main branch, which won't return old_embedding with zero3 enabled.

This may solve this problem in zero3 scenario. But theoretically, there are other ways to disable weight initialization like `no_init_wight` context manager. This patch is still necessary.

Yeah I thought you might be dealing with deepspeed! Should be fixed on main. 
I am not sure we need the patch for such a specific case 

Theoretically, there are other ways to disable model weight initialization. In such scenarios, this may still be an issue.

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.
translate transformers_agents.md to Chinese
Author: jiaqiw09
Pull request: yes

# What does this PR do?

Part of  #26803 

## 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?
- [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.
- [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? _not necessary_


## Who can review?
@stevhliu

Comments:
Hi @stevhliu

I think it's a very interesting doc, although a little hard to translater as it's more like a introductory article than a technical one. 😀

And I think if more docs are translated, it may attract more people to do some contribution. So just do it !

Besides, I find it's hard to make all subfolders update existed files or non-existed files in time when files in en-folder make some change. Maybe you may have some idea or suggestion. You can just comment this issue https://github.com/huggingface/transformers/issues/26803 or just make a new issue ! But it's still a work that will need to be taken care of much later. Currently, just do the translation.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_27046). All of your documentation changes will be reflected on that endpoint.

@stevhliu 

thanks for your review. i just update the file. And for linkS, I just redirect them to files in en folder. and for title, I think it's better to keep transformer_agent untranslated while I just append '教程' to make it more clear. 

Besides, to make it more like a article, what I can do now is just try to translate it more clear rather using normal technical way, which just list step1, step2...

Best

> @stevhliu
> 
> thanks for your review. i just update the file. And for linkS, I just redirect them to files in en folder. and for title, I think it's better to keep transformer_agent untranslated while I just append '教程' to make it more clear.
> 
> Besides, to make it more like a article, what I can do now is just try to translate it more clear rather using normal technical way, which just list step1, step2...
> 
> Best

I think the original English title for this tutorial is "Agents" rather than "transformer_agent"

![image](https://github.com/huggingface/transformers/assets/76979429/24df08cc-85ac-4e38-ac21-2aca4c926b83)
fix _resize_token_embeddings will set lm head size to 0 when enabled deepspeed zero3
Author: kai01ai
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/25977

After resizing the input_embedding, the value of new_embeddings.weight.shape[0] is utilized as the new size for resizing the lm_head. However, when deepspeed zero3 is enabled, this value becomes 0. This PR addresses this issue by updating new_num_tokens explicitly.

## Who can review?
@ArthurZucker, @pacman100



Comments:
cc @amyeroberts 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_26024). All of your documentation changes will be reflected on that endpoint.
fix typo
Author: kai01ai
Pull request: yes

# What does this PR do?

Change `doanloading` to `downloading`  in `src/transformers/modeling_tf_utils.py`


## Before submitting
- [x] 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?

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 and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerz and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

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:
@amyeroberts I've checked, and there are no other instances of 'doanloading'. 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_25981). All of your documentation changes will be reflected on that endpoint.
[`FA-2` / `Mistral`] Supprot fa-2 + right padding + forward
Author: younesbelkada
Pull request: yes

# What does this PR do?

Fixes: https://github.com/huggingface/transformers/issues/26877

There should be no reason to not support right padding + pure forward as the reason to not support generate + right padding + fa-2 is the cache mechanism for that case that slices the cache from the left. 

cc @ArthurZucker 


Comments:
Hi @younesbelkada @ArthurZucker,

Thanks for your contribution !

This patch was removed in this [RP](https://github.com/huggingface/transformers/pull/27086). After tracking the commit history, I think it should be added back ?

Best,
Zhihong

Thansk for noticing @zhjohnchan ! Just made: https://github.com/huggingface/transformers/pull/27125 that should revert the behaviour of this PR
🌐 [i18n-KO] Translated `code_llama.md` to Korean
Author: mjk0618
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다! -->
# What does this PR do?

Translated the `code_llama.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)
@bolizabeth, @nuatmochoi, @heuristicwave, @mjk0618, @keonju2, @harheem, @HongB1, @junejae, @54data, @seank021, @augustinLib, @sronger, @TaeYupNoh, @kj021, @eenzeenee
<!-- 1. 위 체크가 모두 완료된 뒤에, 이 아래에 리뷰를 요청할 팀원들을 멘션해주세요! -->
<!-- May you please review this PR? @member1 @member2 ... -->

## 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)

<!-- 2. 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
<!-- May you please review this PR? @sgugger, @ArthurZucker, @eunseojo -->

Comments:
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.
Swin-B model performance lower than mmpretrain
Author: zhaojun060708
Pull request: no

I tried to train my own dataset using huggingface's transformers and mmpretrain in swin-b model

With the same learning rate and same augmentation pipeline, the performance of huggingface is 4% lower than mmpretrain, any one have met the same with me?

Comments:
Hi,

Which models are you comparing exactly? Did you verify logits match between those models on the same input image?

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.
ImportError: cannot import name 'DeciDiffusionForImageGeneration' from 'transformers'
Author: me-suzy
Pull request: no

### System Info

**I get this error:**

```
Traceback (most recent call last):
  File "E:\Carte\BB\test.py", line 12, in <module>
    from transformers import DeciDiffusionForImageGeneration, DeciDiffusionTokenizer
ImportError: cannot import name 'DeciDiffusionForImageGeneration' from 'transformers' (C:\Users\ME\AppData\Roaming\Python\Python310\site-packages\transformers\__init__.py)
>>> 
```

**I had install all these libraries:**

pip install transformers --upgrade
pip install transformers tokenizers datasets huggingface_hub --upgrade -q
pip install accelerator --upgrade -q
pip install --upgrade accelerate
pip install -U accelerate

But still get that error. 

**This is my testing code:**

```
from transformers import StableDiffusionForImageGeneration, StableDiffusionTokenizer

tokenizer = StableDiffusionTokenizer.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
model = StableDiffusionForImageGeneration.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")

text = "love, home"  # Înlocuiți "YOUR TEXT HERE" cu textul dvs.
inputs = tokenizer(text, return_tensors="pt")
image = model.generate(**inputs)
```

The problem, I believe, is that the file "StableDiffusionForImageGeneration" doesn't exit in

`C:\Users\ME\AppData\Roaming\Python\Python310\site-packages\transformers\`

And after many install and updates, that file isn't there.


### 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, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```
from transformers import StableDiffusionForImageGeneration, StableDiffusionTokenizer

tokenizer = StableDiffusionTokenizer.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
model = StableDiffusionForImageGeneration.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")

text = "love, home"  # Înlocuiți "YOUR TEXT HERE" cu textul dvs.
inputs = tokenizer(text, return_tensors="pt")
image = model.generate(**inputs)
```

### Expected behavior

run Python code

Comments:
Hey! I think you should have a look at the `diffusers` repository instead, `StabelDiffusion` is a diffusion model. See the documentation [here](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview)

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.
Addition of `Flash Attention 2` to MPT
Author: rajveer43
Pull request: yes

# What does this PR do?

Addition of Flash Attention 2 to Mosaic Pretrained Transformers (MPT)

Fixes #26470 
s:

<!-- text models: @ArthurZucker and @younesbelkada -->


Comments:
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.
[`Flash Attention 2`] Add flash attention 2 for MPT
Author: rajveer43
Pull request: no

part of #26350 

Comments:
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.
model.generate(**inputs) breaks when inputs are batched on GPU
Author: vitalyshalumov
Pull request: no

### System Info

- `transformers` version: 4.34.1
- Platform: Linux-5.15.0-1050-azure-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.18.0
- Safetensors version: 0.4.0
- Accelerate version: 0.24.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.1.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 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
- [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

I'm using a generate function on inputs that I put on GPU. I'm using a nllb model.

When everything works:
1. when using a string as an input on cpu
2. when using a string as an input on gpu
3. when using a batch as an input on cpu

When it breaks:
when using a batch as an input on gpu:

Example code: Translation from English to English


```python
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B",src_lang="eng_Latn")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-1.3B")
article ='This does not work' 

#works
#inputs = tokenizer([article, article, article ,article, article], return_tensors="pt")
inputs = tokenizer.batch_encode_plus([article, article, article ,article, article], return_tensors="pt").

#does not work
#inputs = tokenizer([article, article, article ,article, article], return_tensors="pt").to("cuda")
#inputs = tokenizer.batch_encode_plus([article, article, article ,article, article], return_tensors="pt").to("cuda")

translated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.lang_code_to_id["eng_Latn"])
translated_text = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[:]



The error given is:
Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)
  File ..... in <module>
    translated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.lang_code_to_id["eng_Latn"])
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)
```

### Expected behavior

Inference on batched inputs that are on GPU.

Comments:
Doesn't seems like the model was put on the device when you did `inputs.to("cuda")` !Did you try setting `model.to("cuda")` as well? 

model.to('cuda') resolves the issue. Thanks!
[Typo fix] flag config in WANDB
Author: SoyGema
Pull request: yes

# What does this PR do?

<!--

-->

<!-- Remove if not applicable -->

fixes typo in flag for WANDB configuration 
`_` was missing in `--report_to_all`


## 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.
- [ ] 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?
I guess @ArthurZucker 


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_27130). All of your documentation changes will be reflected on that endpoint.