noamaanMulla-03/transformers-issues huggingface dataset:
Remove RuntimeErrors for NaN-checking in 20B
Author: zphang
Pull request: yes

# What does this PR do?

Fixes # (issue)

https://github.com/huggingface/transformers/issues/17452#issuecomment-1142141196

## 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).
- [ ] 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.

@sgugger



Comments:
_The documentation is not available anymore as the PR was closed or merged._
Translation/italian: added pipeline_tutorial.mdx [Issue: #17459]
Author: nickprock
Pull request: yes

- added italian translation of pipeline_tutorial.mdx
- updated _toctree.yml

Comments:
Hi @nickprock! Thank you very much for your contribution to the 🤗 Italian documentation! 🌈
Can I ask you if you can fix a couple of things?

- "Usare uno specifico tokenizer or modello" -->  "Usare uno specifico tokenizer o modello"
- "La mansione text-generation ha un [~generation_utils.GenerationMixin.generate] metodo" --> La mansione text-generation ha un metodo [~generation_utils.GenerationMixin.generate]
- Here seeing the formatting I think there are missing quotation marks "[AutoTokenizer']. Ad esempio, carica la classe [AutoModelForCausalLM`]", I think the problem is also there in the English doc, if you can fix it for the ita one and then I will fix it for the eng version
- "Trova un [audio classification](https://huggingface.co/models?pipeline_tag=audio-classification) modello  per eseguire emotion recognition" --> "Trova un modello per la [classificazione audio](https://huggingface.co/models?pipeline_tag=audio-classification)  per eseguire un compito di riconoscimento automatico delle emozioni"

Thanks! 🚀

Thanks @mfumanelli,
I correct and submit.
One question, how do you translate task? I used "compito", "mansione", "attività".

Thanks for the great PR @nickprock! And @mfumanelli for the amazing review 🚀

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

Yes @nickprock, I agree with you, I also use "compito." It would be more natural for me to leave the English word "task" directly, so I also had this doubt. In my opinion, "compito", "mansione" and "attività" are actually the best words with which to translate the word "task".  🤗

btw, looks perfect to me now! 


@nickprock grazie for the great PR! @mfumanelli grazie for the detailed review! 

I am learning Italian with your work! 

@sgugger LGTM :)

*PR related to #17459.

sorry, there was a little problem.  I absentmindedly pushed my updates to the same branch.  I undo but a check fails

Thanks a lot for this new translation (the failure in Build PR doc is spurious here).
[deepspeed / testing] reset global state
Author: stas00
Pull request: yes

This PR:
- adds a reset to the global state at the end of each in-pytest deepspeed test (and API to do that)
- fixes `test_load_best_model_zero2_fp16` to run the trainingargs first to get the ds config state right

cc: @ydshieh, who discovered the issues on CI

@sgugger 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Padding vs truncation logging mixup
Author: mrtoronto
Pull request: no

https://github.com/huggingface/transformers/blob/31ec2cb2badfbdd4c1ac9c6c9b8a74e974984206/src/transformers/tokenization_utils_base.py#L1470

Looks like this error should probably say truncation side instead of padding side.

Comments:
Correct! Would you like to open a PR to patch 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.
Add magic method to our TF models to convert datasets with column inference
Author: Rocketknight1
Pull request: yes

Left to do:

- [x] Add docstring
- [x] Figure out what type to set for `dataset` (since `datasets` isn't imported)
- [x] Set default values for `batch_size` / `shuffle`?
- [x] Do we need to document this anywhere besides the docstring?
- [x] Anything else I forgot? (Reviewers please yell at me)

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

Hey all, this is the method in `transformers` that I moved all the column inference code to! I also need some advice:

- How do we handle an input type of `Dataset` when `datasets` may not be installed?
- Should this be moved to a utility function that takes `model` as an argument rather than a method on `TFPreTrainedModel`?
- Should I set default values for any arguments to reduce the amount of typing users have to do?
- How should I make sure users find out about this (besides revamping the examples and notebooks once it's merged)?

> Should this be moved to a utility function that takes model as an argument rather than a method on TFPreTrainedModel?

All our models inherit from `TFPreTrainedModel`, so it should be fine

> Should I set default values for any arguments to reduce the amount of typing users have to do?

I'd keep the same defaults as in `datasets`, for a consistent experience. But I'm not the most experienced in this domain :D

> How should I make sure users find out about this (besides revamping the examples and notebooks once it's merged)?

We are getting to the point where we have a lot of content to announce (these changes, the metrics working correctly, generate and its updates, new models, ...), maybe we can start a once-a-week TF communication of some sort! 

Quick update: I think this is ready to merge, but I've only really tested it with the updated `to_tf_dataset()` method in datasets, which hasn't been merged yet (but is due very soon!). As such, I don't want to merge it until that's in, because there could be edge case issues with the old method that I haven't seen.

I've merged the `to_tf_dataset` update so I'm going to merge this one too - though I think it will be a silent 'soft launch' until there's a new release of `datasets`, to avoid any unforeseen problems. Since this code only adds the new method, it shouldn't disrupt any existing workflows before it's ready to be used.
Fix circular import in onnx.utils
Author: sgugger
Pull request: yes

# What does this PR do?

This PR fixes the circular import in `onnx.utils` that one can experiment right now with:
```py
from transformers.onnx import OnnxConfig
```

It comes form the fact that `onnx.utils` imports `AutoProcessor`, `AutoFeatureExtractor` and `AutoTokenizer`, which then requires all models to be initialized, which in turns requires all configs to be initialized and relies on `OnnxConfig`, hence a circular import.

Supercedes #17576 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Enable PyTorch nightly build CI
Author: ydshieh
Pull request: yes

# What does this PR do?

- Make necessary changes to build `huggingface/transformers-pytorch-nightly-gpu`
- Update `self-nightly-scheduled.yml` to run PyTorch nightly build CI (almost a copy from scheduled CI)

[A run](https://github.com/huggingface/transformers/actions/runs/2347272872) here.

<img width="280" alt="Screenshot 2022-05-18 200718" src="https://user-images.githubusercontent.com/2521628/169114866-cba45123-e388-401d-ab1e-89d04b94b0e9.png">


**Some issue**

The job `run_tests_torch_cuda_extensions_gpu` job couldn't use the image
`huggingface/transformers-pytorch-nightly-gpu`.

In scheduled CI, that job uses `huggingface/transformers-pytorch-deepspeed-latest-gpu`. But so far I haven't do an equivalence to that image for nightly PyTorch.

Would like to hear @LysandreJik regarding this part. Maybe update `transformers-pytorch-deepspeed-latest-gpu/Dockerfile` to have an argument, or just a new Docker file (probably easier)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
automatically update config file for models
Author: artemisep
Pull request: no

### Feature request

automatically update config files for large number of models


### Motivation

For the ONNXConfig project https://github.com/huggingface/transformers/issues/16308 where onnxConfig need to be added to 90 models.  Currently it is done manually, mostly copy paste.  Can this be done automatically?  Does this kind of config updates happen often and could this be done in a more automatic way?

### Your contribution

I'm interested in helping with the implementation

Comments:
cc @lewtun @michaelbenayoun 

Hi @Ruihua-Fang, 
Due to the variety of models we support, I think it would be hard to have a very generic class that handles all cases. 
That being said we can still work on making the base classes the most generic possible so that adding model specific ONNX configs becomes easier.

Hi Michael, thanks for the clarification and I am closing this for now.
Bert: relative_key position embedding causes error for long sequences
Author: cedricrupb
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.9.2
- Platform: Linux-5.14.15-arch1-1-x86_64-with-glibc2.33
- Python version: 3.9.7
- PyTorch version (GPU?): 1.9.0+cu111 (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?: no
- Using distributed or parallel set-up in script?: no
```


### Who can help?

@LysandreJik

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

1. Copy paste script from below and run
2. Script:
```python
import torch
from transformers import BertConfig, BertModel

config = {
  'hidden_size': 512,
  'num_attention_heads': 8,
  'position_embedding_type': 'relative_key',
  'max_seq_length': 10,
  'max_position_embeddings': 10
}
encoder_config = BertConfig(**config)
model = BertModel(encoder_config)

batch_size, src_len = 1, 11
x = torch.zeros(batch_size, src_len).int()

model(input_ids=x)
```

### Expected behavior

```shell
Since relative attention is used (Shaw et al.) the script should run without any errors.

However, the script breaks because at least two implementations details (in the PyTorch implementation) prevent this use case:

1. Token type ids are buffered for a specific max. length:
https://github.com/huggingface/transformers/blob/ede5e041911afed37c8284a980342d4a2625b1d5/src/transformers/models/bert/modeling_bert.py#L223

2. The distance in self-attention is not clipped to the maximum distance (as in Shaw et al.):
https://github.com/huggingface/transformers/blob/ede5e041911afed37c8284a980342d4a2625b1d5/src/transformers/models/bert/modeling_bert.py#L328

There is currently no apparent way to prevent this (especially when the model is trained).
```


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.
Spanish Docs - fix gendered sentence
Author: omarespejel
Pull request: yes

# What does this PR do?
Fixes a gendered sentence in [es/index.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/es/index.mdx).

## Notes
FYI @osanseviero, I believe this was the sentence that was still gendered in the Spanish docs :)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
[CLIP] Add padding embeddings
Author: anton-l
Pull request: yes

# What does this PR do?

This PR adds optional per-token padding embeddings (not the usual kind of padding, these are closer to postion embeddings in implementation).

These are needed to convert GLIDE text encoders: https://github.com/openai/glide-text2im/blob/18bf97a07446874693263715af6a73a09cbe81e2/glide_text2im/text2im_model.py#L66


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

Nevermind, had to rewrite the whole attention layer for GLIDE anyway, so I'll just add a new model
Add installation.mdx Italian translation
Author: mfumanelli
Pull request: yes

# What does this PR do?

Italian translation of doc related to the installation of 🤗 Transformers.

See issue: #17459 


## 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).

@omarespejel 

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

Grazie @mfumanelli! 

LGTM @sgugger :)
quicktour.mdx en -> pt translation
Author: vitorfrois
Pull request: yes

# What does this PR do?

Translate en/quicktour.mdx into a brazilian portuguese version.
May be worth checking some words and terms translation to maintain continuity between all portuguese translations.

## 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).
- [x] 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:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


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

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.

Thank you @vitorfrois for the PR! Sorry for the late reply I lost track of the PR. Relates to  #16824.

@sgugger LGTM :). I think the test error in "`Build PR Documentation / build / build_pr_documentation`" relates mostly to a JS issue.

Thanks a lot!
Add examples telemetry
Author: sgugger
Pull request: yes

# What does this PR do?

This PR adds a function to send telemetry to help us track the examples usage and uses it in the current examples. For now, I've just added in the PyTorch `run_glue.py`, but will paste it in all other examples if you agree with the format/data tracked.

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

Thanks a lot for working on this @sgugger - that's super useful!
MT5Model(MT5Config()) fails with AttributeError: 'MT5Config' object has no attribute 'is_gated_act'
Author: pbelevich
Pull request: no
Labels: name: bug

### System Info

```shell
current main branch, 4.20.0.dev0
```


### Who can help?

@patrickvonplaten @sgugger

### 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 *

model = MT5ForConditionalGeneration(MT5Config())
```

### Expected behavior

no error

Comments:
I think it was introduced in https://github.com/huggingface/transformers/pull/17420

cc @patil-suraj as well.
It would also be interesting to understand how it was not caught by any of the tests.
CLI: add stricter automatic checks to `pt-to-tf`
Author: gante
Pull request: yes

# What does this PR do?

Last week I introduced the `pt-to-tf` CLI (https://github.com/huggingface/transformers/pull/17497), enabling automatic weight conversion followed by PR opening.

This PR makes four changes related to that CLI:
1. Uses the appropriate model class to load the model, to ensure the head's weights also get converted;
2. Adds much stricter checks -- ALL model outputs (with `output_hidden_states=True`) are verified;
3. Adds a flag to create new TF weights, even if they already exist;
4. Updates the docker file for the scheduled tests to install `git lfs` -- I did it for the circleci workflows in the original PR, but forgot to do it for the scheduled tests.

🚨 This also means I will double-check previously open Hub PRs (about 10), to confirm that the model head is present in the TF weights (I suspect it isn't in some cases 😢 ) and that the outputs pass the stricter tests.

For context, if the conversion fails because of a difference in the model outputs, we get a message like this one:
<img width="1013" alt="Screenshot 2022-06-07 at 17 00 12" src="https://user-images.githubusercontent.com/12240844/172427441-e1fd63e4-7887-47bf-8827-9209bc1df78a.png">

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

LGTM, just a few nits if they make sense.
It's indeed very important regarding the `head`, great catch, @gante !
Explicit versions in docker files
Author: ydshieh
Pull request: yes

# What does this PR do?

@stas00 Here is the thread to discuss the version things in docker files.

- Objective:

  - We have more 3rd party libraries that depend on PyTorch version
  - Some of them need explicit versions, instead of using something like `$PYTORCH_VER`. For example, we have [1.11.200](https://www.intel.com/content/dam/develop/external/us/en/documents/ipex/whl-stable.html) in `intel_extension_for_pytorch-1.11.200+cpu-cp38-cp38-linux_x86_64.whl`
  - @stas00 suggest to specify the versions in the docker file(s), so we have better control.

- Implementation
  - The current attempt is not very good once we have more and more docker files, but so far it's OK.
  - If this is fine, I can **apply the same change to other docker files**.

Comments:
@stas00 

Do you think we can keep `pip install torch` (latest release), and for 3rd party libraries, we use explicit versions?
(of course, we still need to update them when they have new releases)

Or you really prefer to set all of them (including `torch`) explicitly in docker file, and we update it when new release(s) are available?

WDYT, @LysandreJik 

The reason I proposed to write out the explicit version is because the 3rd parties will fail if they are not adjusted (and of course provided the new builds) - so why not change everything in sync after validating the 3rd parties provide the new builds and not switch to the very latest until this happens.

So this is another good reason actually, if the 3rd party hasn't made a new build yet, after a new pytorch release, we shouldn't update pytorch.

Of course, this requires us to keep up to date with pytorch releases and act on it in a timely manner - e.g. for the last 3 pt cycles I asked torch-scatter owner to make a new release before updating our CI workflow files. 

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

For the record: 

Currently only `docker/transformers-all-latest-gpu/Dockerfile` is changed.

Since we don't install `intel_extension_for_pytorch` in other docker files (so far), and `torch-scatter` is fine with `torch` version, so I just keep as it is for now.