noamaanMulla-03/transformers-issues huggingface dataset:
Cannot import name 'deepspeed_reinit' from 'transformers.deepspeed'
Author: rubenCrayon
Pull request: no

### System Info

Bug found when following the optimization steps provided in **https://huggingface.co/blog/optimum-inference.** 

It seems like transformers/deepspeed.py does not contain the method '**deepspeed_reinit**' so it's not possible to import it when loading ORTModel objects. 

Thanks in advance for your incredible work.  @stas00, @pacman100


### Who can help?

_No response_

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

Install optimum[onnxruntime]==1.2.0

Run: from optimum.onnxruntime import ORTModelForQuestionAnswering or import optimum.onnxruntime

### Expected behavior

The package should import the ORTModels without any issue, enabling the optimization of the ONNX models using DeepSpeed

Comments:
Hi @rubenCrayon!
`deepspeed_reinit` was removed a few versions ago, you should use a more recent version of Optimum. Which may requires to change your script a bit, in that case I recommend that you open an issue in Optimum: https://github.com/huggingface/optimum/issues

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.
Two tfevent files are being generated for each run of trainer
Author: XanderWA
Pull request: no

### System Info

Each run of the trainer two tfevent files are being generated, it looks like this:
/runs
--Feb27_09-46-42_...
----events.out.tfevents....0
----/1677491207.0429652
------events.out.tfevents....1

When reading these files with TensorBoard I don't get any output from the .1 file, how can I get rid of it (because these clutter my TensorBoard) or get actual data from it?

Thanks in advance

@sgugger 

### 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

Simply starting any training.

### Expected behavior

One tfevents file or a valid output from the .1 file.

Comments:
I have no idea. Let us know if you find the reason/how to fix it!

also face this issue by adding the tensorboard callback in the examples/language_modeling/run_mlm.py

Face the same issue:
- transformers: 4.26.1
- tensorboard: 2.12.0

Also faces this issue
As a workaround, I use this command to delete the duplicated directory if somebody is really annoyed by this.
```bash
 find . -type d -name "*[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9]" -exec rm -rv {} \;
```


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.
`local_files_only=True` not work
Author: huchinlp
Pull request: no
Labels: name: bug

### System Info

torch                   1.12.1
transformers            4.21.1

### 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, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I have downloaded the pretrained weights and the model worked well.
I am confused by the long loading time (~25s on a SSD) when using the `from_pretrained` API, and I set `local_files_only=True` to disable connections.
But I still found the function called a http request and it spent many seconds on my desktop without Internet.
Here is my log file:

> File "/disk1/fewshot/anaconda3/envs/pet/lib/python3.9/site-packages/transformers/utils/hub.py", line 284, in cached_path
>     output_path = get_from_cache(
>   File "/disk1/fewshot/anaconda3/envs/pet/lib/python3.9/site-packages/transformers/utils/hub.py", line 501, in get_from_cache
>     r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=etag_timeout)


### Expected behavior

When set `local_files_only=True`, it should disable connections to the website.

Comments:
how did you solve it?
🌐 [i18n-KO] Translated `installation.mdx` to Korean
Author: wonhyeongseo
Pull request: yes

# What does this PR do?

Translated the `installation.mdx` file of the documentation to Korean.
Thank you in advance for your review. 

<!-- Remove if not applicable -->

Part of https://github.com/huggingface/transformers/issues/20179


## 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?
@sgugger, @ArthurZucker, @eunseojo may you please review this PR?

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix DeiT Masked Image Modeling output
Author: alaradirik
Pull request: yes

# What does this PR do?
Fixes the output of `DeiTForMaskedImageModeling` and `TFDeiTForMaskedImageModeling` by replacing the inaccurate `MaskedLMOutput` with the `MaskedImageCompletionOutput` class.

Follow-up PR on #22152 

## 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?




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

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.
Key error during Training 
Author: kashalakarthik
Pull request: no

We are trying to do text summarization using BERT2BERT model. But facing this error mentioned below:
The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
[/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py](https://localhost:8080/#) in get_loc(self, key, method, tolerance)
   3361                 return self._engine.get_loc(casted_key)
   3362             except KeyError as err:
-> 3363                 raise KeyError(key) from err
   3364 
   3365         if is_scalar(key) and isna(key) and not self.hasnans:

KeyError: 6868

Link for google collab:
![error img](https://user-images.githubusercontent.com/90444415/224336228-f39d1e76-3542-4028-9eb4-c0aded3bc762.png)
[https://colab.research.google.com/drive/1ySZS1VifUxbccI81y9dLOHxg_nr9mSc0?usp=sharing](url)

Comments:
Without seeing the code you run or the whole traceback, there is nothing we can do to help you.

The below is the code link, you can access it:
[https://colab.research.google.com/drive/1ySZS1VifUxbccI81y9dLOHxg_nr9mSc0?usp=sharing](url)

> Without seeing the code you run or the whole traceback, there is nothing we can do to help you.

The below is the code link, you can access it:
[https://colab.research.google.com/drive/1ySZS1VifUxbccI81y9dLOHxg_nr9mSc0?usp=sharing](https://github.com/huggingface/transformers/issues/url)

The link does not point to anything.

Sorry about that, Please use the link below mentioned:
https://github.com/kashalakarthik/BERT-Hugging-face

please copy paste the link in browser if it is not working.
The links to download the dataset also mentioned in the repository.

You are not passing a `dataset` to your Trainer but a pandas dataframe, so this can't work. The Trainer only accepts PyTorch `Dataset` objects.

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.
Some problems when using vit model
Author: vegetablelearning
Pull request: no

### Feature request

I am a novice in AI. Recently, I am learning the vit model. There are many teaching about nlp in the document. I want to know how to load the vit model downloaded from the hugging face, and how to use the imagenet dataset to train and test the vit model. I can't find the relevant tutorial. My question is really very basic. If you can answer my question with a simple code, I will be grateful.

### Motivation

Better use of the tansforms library.

### Your contribution

No contribution at present.

Comments:
Better use the [forums](https://discuss.huggingface.co/) for questions like this as we keep issues for bugs and feature requests only.

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.
Why Bloom tokenizer use padding to max_length it will placed the padding tokens to the head ?
Author: svjack
Pull request: no

As the title say,
The following snippet produce:
```python
native_tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-560m", 
                                                      use_fast=False)
caption = "a bear in the woods."
tokenized_data = native_tokenizer(
          caption,
          return_tensors="pt",
          padding='max_length',
          truncation=True,
          max_length=56)
tokens = tokenized_data.input_ids[0]
tokens
```
produce:
```python
tensor([     3,      3,      3,      3,      3,      3,      3,      3,      3,
             3,      3,      3,      3,      3,      3,      3,      3,      3,
             3,      3,      3,      3,      3,      3,      3,      3,      3,
             3,      3,      3,      3,      3,      3,      3,      3,      3,
             3,      3,      3,      3,      3,      3,      3,      3,      3,
             3,      3,      3,      3,      3,     68,  50507,    361,    368,
        165526,     17])
```
It pad the pad_token_id "3" to the head, not tail.
This is different with other models.
Why this occurred ?

Comments:
That's because BLOOM is a generative models, and when using `generate` padding should go on the left for better results. This is thus the default behavior of its tokenizer.

> That's because BLOOM is a generative models, and when using `generate` padding should go on the left for better results. This is thus the default behavior of its tokenizer.

Is there exist a build in simple api method to change this  activity ?

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.
Custom dataset builder for multichannel 'float32' hyperspectral images?
Author: petteriTeikari
Pull request: no

### Feature request

Is there an easy way to train e.g. `ViTMAE` using hyperspectral images (more than 3 "color" channels), and could (or is there already) a best practice on how to load all the images with `tifffile` (would return `np.ndarray` 3D cubes per tiff file) instead of the typical `PIL`?

### Motivation

I wanted to test the [ViTMAE](https://huggingface.co/docs/transformers/model_doc/vit_mae) [1,2] (as it allowed _n_ > 3 channels) quickly for an existing hyperspectral datasets (that had 58 channels instead of the typical 3 for RGB, e.g. `np_array.shape = (58, 48, 48)` with low spatial resolution) and bumped into several painpoints. 

Like:

1) `dataset = load_dataset("imagefolder", data_dir=base_dir)` is supersimple, but then creates a standard PIL-based dataset, whereas I wanted to use `tifffile` to load my hyperspectral files that give me 3d arrays/tensors instead having to rely on ["multipage hacks" with PILs](https://stackoverflow.com/questions/18602525/python-pil-for-loop-to-work-with-multi-image-tiff)

2) Tried to create a custom "loading script" based on the [`Food101` script](https://huggingface.co/datasets/food101/blob/main/food101.py), and wrote an own `Cube()` class instead of the standard `Image()` class. That pretty much just replaced `image = PIL.Image.open(path)` with `image = tifffile.imread(path)`

and then my `_generate_examples()`  returns this `yield abs_file_path, {"image": tifffile.imread(abs_file_path).astype('uint8'), "label": label}`

which results in this warning `TypeError('Unsupported array dtype float64 for image encoding. Only uint8 is supported for multi-channel arrays.')` as PIL prefers the `uint8`types whereas my data is now `float32` as it comes from my a custom preprocessing script.

**Summary**

So could not really find a good example on how to define loaders for new types of data (or is everything going back to PIL always?)

**References**

i.e. have more industry standard implementation of these eventually, or similar:

[1] [Ibañez et al. (2022)](https://doi.org/10.1109/TGRS.2022.3217892): "Masked Auto-Encoding Spectral–Spatial Transformer for Hyperspectral Image Classification"

[2] [Xu et al. (2023)](https://arxiv.org/abs/2212.13805): "Swin MAE: Masked Autoencoders for Small Datasets"


### Your contribution

I don't have a working code for training these and was wondering if there is an easy way even. Like probably need to be careful with some of the `Transforms` if they only support 3 color channels

Comments:
This question might be better suited for the [forums](https://discuss.huggingface.co/) as we keep issues for bugs and feature requests only.

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 sneaky torch dependency in TF example
Author: Rocketknight1
Pull request: yes

Thanks to @muellerzr for uncovering this one - the TF image classification example sneakily depended on `torch` because it used `MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING` (which is a dummy if `torch` is unavailable) and called one of the `TrainingArguments` properties that requires `torch`. Made a quick PR to fix it!

Comments:
_The documentation is not available anymore as the PR was closed or merged._
🌐 [i18n-KO] Translated `tasks/translation.mdx` to Korean
Author: wonhyeongseo
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.mdx` to Korean" 으로 부탁드립니당 -->
# What does this PR do?

Translated the `tasks/translation.mdx` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179
<!-- 메인 이슈에 기록이 남아요! 가짜연구소 리포를 사용해 연습하실때는 제거해주시면 감사하겠습니다! :smile: -->

## 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?

<!-- 제출 전 체크리스트로, 가짜연구소만의 체크리스트도 <details>로 감싸서 만들어두면 더 좋을 것 같아요. -->

## Who can review?
<!-- 가짜연구소 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
@sgugger, @ArthurZucker, @eunseojo May you please review this PR?

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Don't use `LayoutLMv2` and `LayoutLMv3` in some pipeline tests
Author: ydshieh
Pull request: yes

# What does this PR do?

These 2 models require **different input format** than those of usual text models. See the relevant code block at the end.
The offline discussion with @NielsRogge is that **these 2 models are only for DocQA pipeline**, despite they have implementations for different head tasks. 

Therefore, this PR **removes these 2 models from being tested (pipeline) in the first place**, instead of skipping them at later point.
**IMO, we should also remove these models being used in the pipeline classes (except DocQA)** if they are not going to work. But I don't do anything on this.

**`LayoutLMv3` with `DocumentQuestionAnsweringPipeline` (and the pipeline test) is still not working due to some issue. We need to discuss with @NielsRogge to see if it could be fixed, but it's out of this PR's scope.**

### relevant code block
https://github.com/huggingface/transformers/blob/daf53241d6276c0cd932ee8ce3e5b0a403f392b7/src/transformers/models/layoutlmv3/tokenization_layoutlmv3.py#L610-L625

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Merge now as this PR only touches tests. Feel free to leave a comment if any @NielsRogge
New Crash Using Llama
Author: sam-h-bean
Pull request: no

### System Info

Seeing the following crash starting today when loading via accelerate. 
I think maybe related to https://github.com/huggingface/transformers/pull/22785
CC @fpgaminer @gante @amyeroberts 

```
File "/usr/local/lib/python3.8/dist-packages/accelerate/hooks.py", line 165, in new_forward
    output = old_forward(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/transformers/models/llama/modeling_llama.py", line 205, in forward
    query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
  File "/usr/local/lib/python3.8/dist-packages/transformers/models/llama/modeling_llama.py", line 135, in apply_rotary_pos_emb
    cos = cos.squeeze((0, 1))  # [seq_len, dim]
TypeError: squeeze() received an invalid combination of arguments - got (tuple), but expected one of:
 * ()
      didn't match because some of the arguments have invalid types: (!tuple of (int, int)!)
 * (int dim)
      didn't match because some of the arguments have invalid types: (!tuple of (int, int)!)
 * (name dim)
      didn't match because some of the arguments have invalid types: (!tuple of (int, int)!)

```

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

Load Llama on GPU with accelerate and try to generate text.

### Expected behavior

Text is generated

Comments:
@sam-h-bean - Yes, sorry, you're right about the issue and the cause. We're just opening up a PR now to resolve. Thanks for reporting so quickly! 

> @sam-h-bean - Yes, sorry, you're right about the issue and the cause. We're just opening up a PR now to resolve. Thanks for reporting so quickly!

My fault, I didn't see the note in the documentation that tuple inputs to `squeeze` is a new feature of PyTorch 2.0.  If you'd like I can open a pull request to fix by replacing with two `squeeze`s.

No worries @fpgaminer - I should have caught it in the review. @DyeKuu is opening a PR as we type :)
Remove accelerate from tf test reqs
Author: muellerzr
Pull request: yes

# What does this PR do?

This PR removes `accelerate` from the tf example test requirements as I believe its unused and causing issues with the `Accelerate` integration


## 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#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.

@Rocketknight1, @sgugger


Comments:
While the tests aren't being ran here, I did run it on the branch I'm working on (that doesn't touch tf code) and it still passes (and passes now): 
![image](https://user-images.githubusercontent.com/7831895/232113596-a95320b8-43bf-405b-ada2-00e617323dc6.png)


_The documentation is not available anymore as the PR was closed or merged._

Per conversation with @Rocketknight1, not merging this because it actually makes the TF example tests fail. However since they were not run here, we can't test that. (And as a result shows a bug)

This should work now after you rebase on main!
Simplify update metadata job
Author: sgugger
Pull request: yes

# What does this PR do?

This should fix the issue with the update metadata job on main. Simplify the job execution by removing the cached and just doing a pip install dev. Since it's running on main, we don't really care about the 2-3 minutes the cache would make us gain.

Comments:
_The documentation is not available anymore as the PR was closed or merged._