noamaanMulla-03/transformers-issues huggingface dataset:
OPT-fix
Author: younesbelkada
Pull request: yes

# What does this PR do?

Quicklly fxing 3 testing issues! 

cc @patrickvonplaten @ydshieh 


Comments:
Ok let's merge this one first and then I'll rebase mine here: https://github.com/huggingface/transformers/pull/17228

@younesbelkada can you also replace:

```
 tokenizer = GPT2Tokenizer.from_pretrained("patrickvonplaten/opt_gpt2_tokenizer")
```

in the embedding test with 

```
 tokenizer = GPT2Tokenizer.from_pretrained(self.path_model)
```

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

Hi, just a nit:

This line under `OPTGenerationTest`
```
model = OPTForCausalLM.from_pretrained(self.path_model)
```
has `self.path_model` undefined.

And there are still 2 `patrickvonplaten/opt_gpt2_tokenizer` in the current version, but probably these are intended? I will leave this part for you ang Patrick.
fix --gpus option for docker
Author: ydshieh
Pull request: yes

# What does this PR do?

Some multi-GPUs tests in scheduled CI workflow file use `--gpus 0`. I think it is an error, and we might test with only 1 GPU for those multi GPUs tests.

This PR fixes it. 

**Remark**: It's quite strange that, from the setup job log, we can see 2 GPUs in `nvidia-smi` while we have `options: --gpus 0`. I am not 100% sure if this PR has real value, but at least it avoids some confusing maybe.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Quick fix for push CI report channel
Author: ydshieh
Pull request: yes

# What does this PR do?

As title.

I can definitely use 

```
if ci_event == "scheduled":
   ...
else:
   ...
```

Let me know if you prefer that approach, @LysandreJik .

(I updated the secret - despite the channel ID might just be the same as before)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add PR title to push CI report
Author: ydshieh
Pull request: yes

# What does this PR do?

As title. The current effect looks like

<img width="512" alt="Screenshot 2022-05-13 191853" src="https://user-images.githubusercontent.com/2521628/168335363-ddb06fb3-4c3e-40ea-8b3a-2a82e9402c38.png">

I need to figure out a way to add link.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
please add option to load fine-tuned file to CPU if trained on GPU
Author: bsugerman
Pull request: no

I fine-tuned the pytorch_model.bin on a GPU machine (google cloud) but need to use it on my home computer (no GPU). When I tried to open it using `model = BertForMaskedLM.from_pretrained(bert_version)` I got the following error:

     RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() 
     is False. If you are running on a CPU-only machine, please use torch.load with map_location='cpu'
     to map your storages to the CPU.

Perhaps you can add an option into `from_pretrained()`  such as `cpu=True` which will then call

`torch.load(weights_path, map_location=lambda storage, location: 'cpu')`

Comments:
Indeed, this will be in the next release, thanks!

is there is a change according the CPU issue ?

Should be fixed now. Do you still have an error?

i am loading the model and i dont know how to load on CPU , gives me "model.to" to is not defined. Can you tell me how to send the model to run on CPU if trained on GPU.

Would love some explanation on how to do this as well!

I have the same question. how to load a model trained on GPU to CPU?

I am watching this as well.

I have the same question. Is there any option for using CPU-only?

watching this as well

same
[ fast_tokenizers.mdx ] - Added translation to portuguese to tutorial
Author: Fellip15
Pull request: yes

# What does this PR do?

Creates folder pt in docs/source for translating documentation to Portuguese
Currently, only the installation.mdx file was translated as of this PR.

Fixes issue #16824

## 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?

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

@Fellip15 muito obrigado! I will be reviewing it.

@sgugger LGTM 🔥
Translated version of model_sharing.mdx doc to spanish
Author: Gerard-170
Pull request: yes

# What does this PR do?
This PR is related to #15947  issue.

This PR translates the model_sharing.mdx file to a spanish version of it and save it into transformers\docs\source_es path. This translation tries to keep the structure and ideas behind each statement, adding some words and translation where there's not specific one-to-one translation in Spanish, in other cases it adds words for a better flow of ideas. 

Any comment with respect to this translation is welcome while we try to figure out the better way to give Spanish-speaker community the best documentation about HuggingFace. 

Thank you.


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

Thanks, @Gerard-170! I will review it during the week :)

Hola @Gerard-170! I just wanted to follow up with your PR 🤗! Please let me know if you need anything else.

Hi! @omarespejel  Well I was waiting the review. whether you have some comments about the translation or not. Let me know what you think! and Happy to contribute!! Thank you! :D 

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.

Hi @Gerard-170! Thank you 🤗. I left above my review.

Also, could you please add `model_sharing` to [`transformers/docs/source/es/_toctree.yml`](https://github.com/huggingface/transformers/blob/main/docs/source/es/_toctree.yml)? As a reference, you can use the [new Translation](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md) guide (section "✍️ Start translating"). This would allow the tests to pass.

Hi! Sorry for a late response, of course I will add model_sharing to [transformers/docs/source/es/_toctree.yml](https://github.com/huggingface/transformers/blob/main/docs/source/es/_toctree.yml). 

Thank you @Gerard-170! Also please run `git pull upstream master` to merge all the changes made to `main` (note we recently went from `master` to `main`, and this is still not reflected in your fork).

Hola @Gerard-170! Muchas gracias. It looks great, there is a style error that we recently corrected in another file. Could you please run `git pull upstream main` again so this gets corrected? I think this will do the trick.

Hola @omarespejel Yes! I did again git pull and all checks have passed! :D Please let me know if you need something else. Gracias! 

Thank you @Gerard-170! This is great 🤗.

@sgugger LGTM 👍
Guide to create custom models in Spanish
Author: ignacioct
Pull request: yes

# What does this PR do?

<!--

This PR translates the guide on h[ow to create custom models](https://github.com/huggingface/transformers/blob/main/docs/source/en/create_a_model.mdx) to the Spanish language, as talked in #15947 .
-->

Linked 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).

## Who can review?

@omarespejel said he will review, otherwise anyone 😁.


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

Thanks for the suggestions, I've committed all the changes you proposed.

@ignacioct muchas gracias por tu PR! 🤗 Vamos a hacerle merge. If there is any other doc that you would like to translate you can tell me. 

@sgugger LGTM 🔥
LayoutLMv2Processor: ensure 1-to-1 mapping between images and samples in case of overflowing tokens
Author: garyhlai
Pull request: yes

# What does this PR do?

Fixes #13554

Problem re-summarized: when `return_offsets_mapping` is set to True, `LayoutLMv2Processor` would break up sequences that are too long into multiple `input_ids` sequences, causing a mismatch between `input_ids` (longer in length in the case of overflowing tokens) and `images`. 

This fix would ensure the 1-to-1 mapping between the `images` and `input_ids`. 

**Reproducible Example:** (The assertion at the end would fail without the fix, pass with the fix)

```
import transformers
from PIL import Image
from transformers import LayoutLMv2Processor
from datasets import Features, Sequence, ClassLabel, Value, Array2D, Array3D, load_dataset
import torch

datasets = load_dataset("nielsr/funsd")
labels = datasets['train'].features['ner_tags'].feature.names
id2label = {v: k for v, k in enumerate(labels)}
label2id = {k: v for v, k in enumerate(labels)}

processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")

def preprocess_data(examples):
  images = [Image.open(path).convert("RGB") for path in examples['image_path']]
  words = examples['words']
  boxes = examples['bboxes']
  word_labels = examples['ner_tags']
  encoded_inputs = processor(images, words, boxes=boxes, word_labels=word_labels,
                             padding="max_length", truncation=True,
                             return_overflowing_tokens=True,
                             stride=50,
                             return_offsets_mapping=True,
                             return_tensors="pt")
  return encoded_inputs

train_data = preprocess_data(datasets["train"])

# this assert would fail without this PR fix. 
assert len(train_data["image"]) == len(train_data["input_ids"])
```

## Required Input from Reviewers

Right now, the LayoutLMv2Processor would **return a list** for `encoded_inputs["image"]`, regardless of the value of `return_tensors`. If we want it to return a torch tensor in the case `return_tensors=="pt"`, we have to `torch.stack` the list (and do similar thing to support "np" and "tf"). 

Should I implement this in `get_overflowing_images`? Or should I just leave the return type as list and just print a warning? 

## Who can review?

@NielsRogge @sgugger @LysandreJik 

## P.S.

The `test_processor_case_1` in `test_processor_layoutlmv2.py` fails before this PR. I'd be happy to look at it as well but it's unrelated to this PR.

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

Thanks again for your contribution!

Thanks for handling this @ghlai9665
[TAPEX] Update drop_rows_to_fit
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR makes `drop_rows_to_fit` an attribute of `TapexTokenizer`, rather than a standalone `TruncationStrategy`.

The truncation strategies that can be used are the same as those of BART (as TAPEX is a BART model), meaning `truncation=True` will truncate to the maximum length. However, one can still randomly drop rows based on answers using this attribute.

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.

Closing this as "drop_rows_to_fit" probably deserves to be a truncation strategy on its own.
KeyError: 'loss' while trying to finetune Bart model on custom dataset for summarization.
Author: Kiera-K
Pull request: no

I am trying to finetune BART on my custom dataset by following a huggingface finetuning tutorial. 


<img width="796" alt="Screen Shot 2022-04-05 at 10 29 54 AM" src="https://user-images.githubusercontent.com/78582210/161777173-50af5514-443e-429e-9a99-468c50fe4e03.png">
<img width="846" alt="Screen Shot 2022-04-05 at 10 33 33 AM" src="https://user-images.githubusercontent.com/78582210/161777920-67c25cf2-afe6-435a-8b46-d3d1e639d394.png">
<img width="485" alt="Screen Shot 2022-04-05 at 10 34 05 AM" src="https://user-images.githubusercontent.com/78582210/161778025-2eeafd95-e21d-4385-b265-1c33cdf15d0a.png">
<img width="731" alt="Screen Shot 2022-04-05 at 10 34 24 AM" src="https://user-images.githubusercontent.com/78582210/161778096-c5ab1a96-8bdc-4337-b320-54812993ee0d.png">
At which point I am met with the keyError: 'loss' error. I looked at https://discuss.huggingface.co/t/keyerror-loss-during-fine-tuning-bert-base-italian-cased-for-qa/6638/2 but wasn't able to figure it out for my code. Please help!


@sgugger 

Comments:
Please use the forums to debug your code. You are using the base model class here, that does not accept `labels` and does not return a loss. You should use a model that can be fine-tuned on your task.

@sgugger Apologies for that and thank you for letting me know. All articles for BART finetuning I came across use the `pretrained_model_name = "facebook/bart-large-cnn"` model. Is there a small version like "t5-small" ? 

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.
version 4.2.0 vs newer version
Author: PNMinh286
Pull request: no

I have this problem with ver 4.2.0+ but is ok for under ver. Can anyone help me because other parts of my project were used ver 4.10+
![image](https://user-images.githubusercontent.com/75312938/161733457-088d19fd-4176-4c5c-902c-169efefca361.png)


Comments:
Hi @PNMinh286 👋   The information you provided is not enough for us to help you, as we don't know exactly what you're to do :) Ideally, a script with which we can reproduce the issue should be provided. Have a look at our [issue guidelines](https://github.com/huggingface/transformers/blob/main/ISSUES.md).

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.
Only get generated text from Bart Generate
Author: musitafa0032
Pull request: no

I know Bart can be used to fill in Multi masked tokens with only one [mask], but how can I only get filled in /generated text, not the whole sentence! If it is single token, I can figure it out, but how do I get span of text for multi masked tokens.

Thank you!



Comments:
Hi @musitafa0032 ! The best place to ask this question would the [forum](https://discuss.huggingface.co/). We use issues for bug reports and feature requests. Thanks!

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.
Checkpoints are NOT save in GCS (Google Cloud Storage)
Author: JessicaLopezEspejel
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.18.0
- Platform: Linux-5.4.144+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.13
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.10.0+cu111 (True)
- Tensorflow version (GPU?): 2.8.0 (True)
- 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?

@patrickvonplaten @patil-suraj @sgugger

### 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

Steps to reproduce the behavior:

I am working with BART model in Google Colab:
```
from google.colab import auth

auth.authenticate_user()

project_id = "my_project_id"
!gcloud config set project {project_id}

tokenizer = BartTokenizer.from_pretrained('facebook/bart-base')
model = BartForConditionalGeneration.from_pretrained('facebook/bart-base')
....
training_args = Seq2SeqTrainingArguments(output_dir='gs://my_bucket/models/') 

```





### Expected behavior

```shell
It is supposed to save the checkpoints in GCS (Google Cloud Storage). However, it is saving the checkpoints in my local.

In fact, I can see my files if I type:


!gsutil ls gs://my_bucket/
```

But I can not save my checkpoints.

Do you have any idea how can I fix it?

Thank you in advance.
```


Comments:
Hi @JessicaLopezEspejel 👋  Most file writing functions, like `torch.save`, don't support writing to/reading from GCS out of the box. There are a few workarounds:
- [edit] See @mikcnt comment [here](https://github.com/huggingface/transformers/issues/16858#issuecomment-1114924716) 
- Use TensorFlow, whose native read/write functions support GCS when properly implemented (see [this](https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile)) ;)
- Wrap your existing code so as to call read from/write to GCS externally;
- After running your code, manually copy files around with `gsutil -m cp -r ...` ([docs](https://cloud.google.com/storage/docs/gsutil/commands/cp))

Also see this [similar StackOverflow question](https://stackoverflow.com/questions/57898998/is-it-possible-to-load-a-pretrained-pytorch-model-from-a-gcs-bucket-url-without).

Hello @gante

I see, thank you very much. I will try one the workarounds you propose. :)


Hello! I just wanted to clarify a little detail about what @gante said: `torch.save` actually supports writing to GCS! You just need to change the way you use it a bit :) I gave a complete explanation on how to do that [here](https://stackoverflow.com/questions/69100496/not-able-to-save-model-to-gs-bucket-using-torch-save).

Hello @mikcnt, thank you so much! I will try it. 

@mikcnt thanks for the clarification 👍 (gonna post-edit my comment, for future reference)
Wav2Vec2 Conformer Encoder
Author: deepconsc
Pull request: no

# 🚀 Feature request

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

Implementing Conformer version of context encoder for [Wav2Vec2](https://github.com/pytorch/fairseq/blob/main/fairseq/models/wav2vec/wav2vec2.py#L390).



## Motivation

Fairseq has recently updated their Wav2Vec2 codebase, incorporating [Conformer-based](https://github.com/pytorch/fairseq/blob/main/examples/wav2vec/config/pretraining/wav2vec2_conformer_large_librivox.yaml) encoder as an option with already existing Transformer-based version. 

As long as a decent number of the new SOTA-matching papers are utilizing Conformers for either of ctc or transducer models, it would be a great addition to Transformers library to have an option of using transformer or conformer based encoder for [Wav2Vec2ForCTC](https://github.com/huggingface/transformers/blob/main/src/transformers/models/wav2vec2/modeling_wav2vec2.py#L1647)

Some of the papers: [JUST](https://arxiv.org/pdf/2111.08137v1.pdf), [Pushing the Limits of Semi-Supervised Learning for ASR](https://arxiv.org/pdf/2010.10504.pdf)




Comments:
Thanks for letting me know - we should definitely add these conformer models asap. I can take care of this next Tuesday :-) 

Also cc @anton-l 

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.
Fill-in-the-Blank Text Generation of T5
Author: yanan1116
Pull request: no

Hello, any guys know how to implement the `Fill-in-the-Blank Text Generation` of T5 in this post: https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html

Is there any demo codes in huggingface transformers to do this ?

Thanks.

Comments:
I'm wondering the same. I've got pretraining going with the `run_t5_mlm_flax.py` script, which is great(!), but help with fill-in-the-blank generation is my next step.

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.