noamaanMulla-03/transformers-issues huggingface dataset:
Spanish translation of asr.mdx and add_new_pipeline.mdx
Author: alceballosa
Pull request: yes

# What does this PR do?

Translates `asr.mdx` and `add_new_pipeline.mdx` into Spanish. Also updates the `_toctree.yml` file accordingly. Includes minor typo corrections for the original versions of both files and the translated version of a file I had previously worked on.

Related to #15947

## 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?

@osanseviero @sgugger 

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

I think I committed all the suggested changes, thanks @osanseviero !

Thanks again for your contribution!
Fix AutoModelTest.test_model_from_pretrained
Author: ydshieh
Pull request: yes

# What does this PR do?

From @Narsil 

> Hmmmm it's because of safetensors is installed in that environement and it's loading the safetensors weights which have indeed 1 less unexpected keys (the duplicated key was removed)

I tried `gpt2` and `roberta-base`, they also have similar issues, on some keys among `missing_keys`, `unexpected_keys` etc..
I decided to stop trying and just give a condition.

Comments:
The other way to fix would be to modify the original files to remove the duplicated layer. I think that was suggested by @sgugger .

I personally am ok with the proposed fix, it does seem the easiest route.

_The documentation is not available anymore as the PR was closed or merged._
Question-answering example datasets
Author: Arij-Aladel
Pull request: no

In the [examples
](https://github.com/huggingface/transformers/tree/0bae286de94f7131b4a2db3f85754b0961c4aaf5/examples/pytorch/question-answering)
Could you please add possible datasets for each script? Neither in the scripts or in the read me I can find this information. especially for long inputs, as I saw from the scripts that you used a tokenizer for that. Also, it would be great if you could provide us please, with the possible models for each script if possible.

Comments:
The examples are given as just that: examples. You will always need to slightly adapt them when changing the dataset as the data format might not be exactly the same. So there is no official list of possible datasets apart from the ones showcased in the README.
Implement tf big bird port
Author: E-Aho
Pull request: yes

# What does this PR do?
Solves #19430 by implementing BigBird in Tensorflow

I had an earlier demo PR up, but this one will be the main PR I use to hopefully get this merged in once it's all working :)


## 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?
- [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).
- [x] Did you write any new necessary tests?


## Who can review?

Tagging @Rocketknight1 as they were kind enough to help me with this already with an issue I was running into with outputting attention weights using strided slices, but would appreciate any inputs from anyone!

Most of the tests are working as expected now, I am still running into a couple issues with two or three tests, that I need to look into:

1) Issue with TFAutoModel in test not raising a `ValueError` in one of the tests for mismatching sizes (but the `TFAutoModelForSequenceClassification` is working in this test 🤔).
2) Issue persisting and loading (`save_load` and `keras_load` tests aren't working fully yet)

I'm going to try and work on this some more this weekend, if anyone has any insights I'd love to know :D

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20052). 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.
pipeline("summarization") is extractive vs abstractive?
Author: keyuchen21
Pull request: no

### System Info

pipeline("summarization") is extractive vs abstractive?

# use bart in pytorch
summarizer = pipeline("summarization")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

# use t5 in tf
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base", framework="tf")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

### Who can help?

_No response_

### Information

- [X] 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

# use bart in pytorch
summarizer = pipeline("summarization")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

# use t5 in tf
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base", framework="tf")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

### Expected behavior

pipeline("summarization") is extractive vs abstractive? there is no mention about it on the official documentation

Comments:
Please use the [forums](https://discuss.huggingface.co/) for such questions 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.
`device_map="auto"` fails for GPT2 on CPU
Author: dirkgr
Pull request: no

### System Info

Python 3.9, Mac, `transformers==4.21.3`

### Who can help?

@patil-suraj, @patrickvonplaten, @LysandreJik

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

On a box with no GPUs:

```Python
transformers.AutoModelForCausalLM.from_pretrained("gpt2", device_map="auto")
```

### Expected behavior

I'd expect a model. I get an exception.

Comments:
Workaround: Don't use `device_map` on CPU 🤷🏻 

cc @sgugger 

Yes, `device_map="auto"` is not supported in CPU only environments.

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.

Should be supported now on the main branch of Accelerate!

Yay!

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.
Spanish translation of the file debugging.mdx
Author: SimplyJuanjo
Pull request: yes

# What does this PR do?

Fixes #[15947](https://github.com/huggingface/transformers/issues/15947)
Adds the Spanish version of [debugging.mdx](https://github.com/huggingface/transformers/blob/master/docs/source/en/debugging.mdx) to [transformers/docs/source/es](https://github.com/huggingface/transformers/tree/main/docs/source/es)

Also found one typo error in the original doc, so I fixed it also.


## 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.

## Who can review?

@omarespejel @osanseviero  @sgugger 

Comments:
Can you just add the new file to the TOC of the Spanish doc? (in `transformers/docs/source/es/_toctree.yml`)

@sgugger like that is fine? Tried to mimic the eng TOC creating the same section "Rendimiento y escalabilidad"

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

All good, thanks!
Convert tokenizer outputs for Keras in doc example
Author: Rocketknight1
Pull request: yes

The TF examples in `training.mdx` don't turn the tokenizer outputs into a `dict`, so Keras gets confused.

Fixes #20709 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20732). All of your documentation changes will be reflected on that endpoint.
Clarify return_tensor and return_text parameters
Author: stevhliu
Pull request: yes

This PR fixes #20615 by clarifying that setting `return_tensors=True` will not return the decoded text, and you can't get a combination of `generated_text` and `generated_token_ids`.

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

> LGTM thanks! @Narsil maybe a clear `ValueError` could be raised when sanitizing parameters when both `return_text` and `return_tensors` are `True`?

https://github.com/huggingface/transformers/pull/20729
Add vision requirement to image transforms
Author: amyeroberts
Pull request: yes

# What does this PR do?

Addresses issue when importing functions in the `image_transforms` module if Pillow isn't installed. Namely: 
* functions which don't require Pillow have errors when importing. This was because other objects were only imported if Pillow was available e.g. `ChannelDimension`.  Resolved by rearranging imports. 
* Unuseful error message hiding that the issue is with Pillow in the environment. Resolved by adding a `vision_required` decorator to allow for errors only on select functions.  

Fixes #20627 

This needs to be merged in before the transforms can be removed from the init in #20704

Snippet below shows new behaviour when running in an environment without Pillow installed: 

```
>>> import numpy as np
>>> 
>>> # Show we can import both methods without issue
>>> from transformers.image_transforms import rescale
>>> from transformers.image_transforms import center_crop
>>> 
>>> img = np.random.randint(0, 256, (3, 244, 360))
>>> 
>>> # We can call rescale successfully without having Pillow
>>> rescale_img = rescale(img, 10)
>>> print(rescale_img.shape)
(3, 244, 360)

>>> # center_crop call raises error
>>> cropped_img = center_crop(img, (100, 100))
Traceback (most recent call last):
  File "/Users/amyroberts/code/transformers/../scripts/test_image_transforms_imports.py", line 10, in <module>
    cropped_img = center_crop(img, (100, 100))
  File "/Users/amyroberts/code/transformers/src/transformers/utils/import_utils.py", line 1073, in wrapper
    raise ImportError(f"Method `{func.__name__}` requires Pillow.")
ImportError: Method `center_crop` requires Pillow.
```

## 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?


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

A quick question: If we add `requires_backends(center_crop, ["vision"])` in some methods in `src/transformers/image_transforms.py`, shouldn't we do the same in `src/transformers/image_utils.py`, say, `load_image`?


> A quick question: If we add `requires_backends(center_crop, ["vision"])` in some methods in `src/transformers/image_transforms.py`, shouldn't we do the same in `src/transformers/image_utils.py`, say, `load_image`?

Yep. I'll add those in too.
Progress Bar for large model loading
Author: vvvm23
Pull request: no

### Feature request

Add progress bars for large model loading from cache files.

### Motivation

Most of the time, model loading time will be dominated by download speed. However, for very large models we will often first download the checkpoints, then during runtime simply load them from cache. For models like Bloom however, it can take upwards of 100 minutes to load the model into RAM. During this time, there is no feedback to the user, even with verbosity set to debug. This can be frustrating as the only way to check progress is by checking system utilisation through `top`.

### Your contribution

Happy to help if I am pointed to the relevant file or files! I don't think the progress bar would need to be extremely accurate, just some indication that something is happening.

Comments:
Sounds like a reasonable request. This should be done by the PR linked above if you want to try it!

I might be using this wrong, but I've taken the following steps and don't see any changes 🤔 :
```
from transformers import BloomForCausalLM
import torch

model = BloomForCausalLM.from_pretrained('bigscience/bloom-7b1', cache_dir='bloom-7b1-ckpt', torch_dtype=torch.float16)
```
after cloning `transformers`, running checkout on `large_model_progress`, then `pip install -e .`

Is there some edge case with the use of `cache_dir`?

The PR has not been merged into the main branch yet, so you need to checkout the branch of the PR before trying.

I had built the correct branch, the issue was me not being patient enough, as the progress bar did eventually appear.

Seems there is some processing going on between downloading and actually loading the shards. I am not sure what is being done, but the PR works ~

LGTM 🤗
Update CI to PyTorch `1.13.0`
Author: ydshieh
Pull request: yes

# What does this PR do?

The job runs with PT 1.13 show everything is fine except 
```python
test_model_parallelism
(line 980)  RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cuda:1)
```
Once #20686 being merged, we can merge this PR to use PT 1.13 for CI


Comments:
_The documentation is not available anymore as the PR was closed or merged._
T5ForConditionalGeneration with BetterTransformer
Author: R4ZZ3
Pull request: no

### Feature request

Got this error when trying out BetterTransformer:
"The Better Transformers implementation for the model T5ForConditionalGeneration has not been implemented yet. Please open an issue requesting the addition of this model with its `BetterTransformer`implementation."

### Motivation

I would like to speed up some text2text models with BetterTransformer

### Your contribution

I can at least test the feature once it is ready

Comments:
I think it needs to be implemented in optimum, so you should move the issue there. cc @younesbelkada 

Moving to optimum
added model resources for xlm-roberta
Author: hazrulakmal
Pull request: yes

# What does this PR do?

Fixes [20055](https://github.com/huggingface/transformers/issues/20055)

- I created a link to task guides for casual language modeling and text classification. I think they are useful and applicable but not directly related to the xlm-roberta model class per say. 
-  For casual language modeling, should I write it under "text-generation" pipeline tag or create a subheader like multiple choice?
- I've checked notebooks from the community but so far none of them do a tutorial on xlm-roberta. Hopefully, there'll be one soon!
- I've also found a few blog posts related to roberta but not xlm-roberta. should we include them? cus they are technically the same architecture just that one is multi-lingual and the other is not


<!-- Remove if not applicable -->

## Before submitting
- [x] This PR improves the docs of xlm-roberta by adding common and most used resources
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [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).

@stevhliu please check the work and let me know if I need to do any changes. thanks

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add GPT-SW3 models to huggingface
Author: ekgren
Pull request: no
Labels: name: New model

### Model description

At AI Sweden we are developing GPT models for the nordic region. Languages include English, Swedish, Danish, Norwegian and Icelandic. 
The models are of the GPT family.
The models will range in size from 126m to 20B.
They are trained from scratch on a large corpora of 320B tokens.
They are trained with the nemo megatron framework and has a sentencepiece tokenizer.
The weights are not shared yet and we intend to share them through huggingface as well as publishing our training process and results.

### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

Training framework: https://developer.nvidia.com/nemo/megatron

Comments:
PR merged! :partying_face:
Add run_gsg.py and run_gsg_no_trainer.py pre-training scripts to examples
Author: KMFODA
Pull request: no

### Feature request

Models such as Pegasus and LongT5 have been pretrained using Gap Sentences Generation (GSG) strategy rather the typical Masked Language Modelling (MLM). 

This pre-training strategy leads to improved performance in certain language tasks such as [summarisation](https://arxiv.org/pdf/1912.08777.pdf). This request is to add run_gsg_.py and run_gsg_no_trainer.py files in the examples folder that would enable pre-training using the GSG strategy instead of or on top of MLM.

### Motivation

This will enable users to pre-train Pegasus or LongT5 models from scratch or to continue pre-training existing checkpoints on new datasets.

### Your contribution

I've started thinking about how to build this and am happy to contribute a PR if the HF team think this is valuable and can offer advice on the best ways to approach this.

Comments:
We try to avoid having examples that are too specific in the maintained examples, as we don't have the bandwidth for too many of them. How about you host it in a repo of yourself and then link to it from the model pages in our doc as well as the community page?

Ah I see, not problem that seems like a good alternative. Where would be the best place for asking for help with road blocks if I stumble across any?

You can use this issue or the [forums](https://discuss.huggingface.co/) :-)

Thank you @sgugger. I've had to de-prioritise this for due to funding constraints that will delay when we can train a bigger version of LongT5 from scratch so I'll close this for now and if we pick this back up I'll post any qs in the forums.
Add decorator for flaky Donut tests
Author: amyeroberts
Pull request: yes

# What does this PR do?

Tests occasionally fail for Donut. Adding decorator to handle whilst waiting for a resolution to be merged in. 

Issue raised here: https://github.com/huggingface/transformers/issues/20738

## 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?

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

`is_flaky` has to be used as `is_flaky()`, otherwise the actual tests won't be run, and will always pass.
Change a logic in pipeline test regarding TF
Author: ydshieh
Pull request: yes

# What does this PR do?

- **Currently**, the tiny models in pipeline tests are created using `model_class(config)`, and for TF models, the weights are not created at this point. Then we set the device (**which turns to be CPU instead of GPU!**), and the wegiths are created in CPU context --> we get the expected exceptions.
- In the future, we will use the tiny model from Hub repos
- The models are loaded using `from_pretrained`
- If GPU available, those weights are initialized in GPU context automatically for TF models, including embedding layers
- From what @Rocketknight1 says at the end, we won't get the expected exceptions in this situation (TF, layer weights loaded in GPU context)

**In order to use the tiny models from the Hub without any pipeline test failure, we will have to skip this check under the above described situation.**

From @Rocketknight1 
> Embedding layers in Keras have different behaviours on CPU and GPU when you pass invalid indices. On CPU, the layer checks inputs and throws an error if you're out of range, but on GPU you just get a zeros tensor as output with no error

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

cc @gante to this one - he's been working on a way to check for invalid indices even for embedding layers on GPU