noamaanMulla-03/transformers-issues huggingface dataset:
Fix RemBertTokenizerFast
Author: ydshieh
Pull request: yes

# What does this PR do?

`RemBertTokenizer(Fast)` are similar to  `AlbertTokenizer(Fast)`, the slow versions are based on `SentencePiece`.

Unlike `AlbertTokenizerFast`, the fast tokenizer `RemBertTokenizerFast` doesn't have

```python
self.can_save_slow_tokenizer = False if not self.vocab_file else True
```

And I got error when I want to call `save_pretrained()` after doing something like
```
tokenizer_fast.train_new_from_iterator(training_ds["text"], 1024)
```

(while working on the task for creating tiny random models/processor)

### Error message without this PR

```
  File "/home/yih_dar_huggingface_co/transformers/create_dummy_models.py", line 457, in convert_processors
    p.save_pretrained(output_folder)
  File "/home/yih_dar_huggingface_co/transformers/src/transformers/tokenization_utils_base.py", line 2101, in save_pretrained
    save_files = self._save_pretrained(
  File "/home/yih_dar_huggingface_co/transformers/src/transformers/tokenization_utils_fast.py", line 591, in _save_pretrained
    vocab_files = self.save_vocabulary(save_directory, filename_prefix=filename_prefix)
  File "/home/yih_dar_huggingface_co/transformers/src/transformers/models/rembert/tokenization_rembert_fast.py", line 237, in save_vocabulary
    if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file):
  File "/home/yih_dar_huggingface_co/miniconda3/envs/py-3-9/lib/python3.9/posixpath.py", line 375, in abspath
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

Comments:
I could provide the full code sample to reproduce the issue without this PR if necessary.

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

Great to know the test is there (in common) 😄
TF: XLA logits processors - minimum length, forced eos, and forced bos
Author: gante
Pull request: yes

# What does this PR do?

(Review after https://github.com/huggingface/transformers/pull/16899)

A few more XLA-compatible logits processors -- minimum length, forced eos, and forced bos. Only the first one needed changes, mostly to avoid needless retracing (it actually compiled without changes but would trigger a retrace at iteration, which would be super slow).

After this PR, the only remaining processors are the bad words and ngrams ones.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Missing `f` prefix on f-strings
Author: code-review-doctor
Pull request: no

Some strings looks like they're meant to be f-strings but are missing the `f` prefix meaning variable interpolation won't happen.

https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/utils/hub.py#L751
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/configuration_utils.py#L637
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/pipelines/audio_utils.py#L58
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/pipelines/audio_utils.py#L147
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/auto/feature_extraction_auto.py#L310
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/xglm/modeling_flax_xglm.py#L156
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/plbart/modeling_plbart.py#L1025
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/bert/convert_bert_original_tf2_checkpoint_to_pytorch.py#L132
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/bart/modeling_bart.py#L1053
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/src/transformers/models/prophetnet/modeling_prophetnet.py#L760
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/tests/extended/test_trainer_ext.py#L269
https://github.com/huggingface/transformers/blob/d91841315aab55cf1347f4eb59332858525fad0f/examples/research_projects/onnx/summarization/bart_onnx/generation_onnx.py#L642

I found this issue automatically. I'm a bot. Beep Boop 🦊. See other issues I found in your repo [here](https://codereview.doctor/huggingface/transformers)

Comments:
Limit the use of PreTrainedModel.device
Author: sgugger
Pull request: yes

# What does this PR do?

I'm currently working on solutions to do model parallelism, offload weights to the CPU or the hard drive, and I've encountered some bugs linked to the way we use the `PreTrainedModel.device`: it grabs the first parameter of the model to infer a device for the whole model. This doesn't work when the model is:
- split on several devices and the first parameter grabbed happens to be on the wrong one
- not materialized because its parameters are offloaded on the CPU or the hard-drive.

So whenever it's possible, it would be great to rely on something else if we can, for instance some device where the inputs are. This PR does this for every use of this `device` attribute in modeling_utils and generation_utils, with the exception of some code where there are no inputs passed so we generate them and have to use something for the device.

If all works well, I plan to add all modeling files that make use of that attribute (when in the `dummy_inputs`, I'll leave the `self.device` but outside of it, will grab the device of any inputs we have).

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Labels shift in seq2seq example
Author: markovalexander
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.15.0
- Platform: Linux-4.15.0-54-generic-x86_64-with-glibc2.10
- Python version: 3.8.5
- PyTorch version (GPU?): 1.8.1+cu101 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

@sgugger, @patil-suraj

### 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

Just run https://github.com/huggingface/transformers/blob/main/examples/pytorch/translation/run_translation.py script

### Expected behavior

For each token in seq2seq target sequence we have to predict the next token. However, i did not found this shift by one token in translation example neither in code nor in sources (I checked tokenizer.as_target_tokenizer, for example)

It can be added in this line https://github.com/huggingface/transformers/blob/fa322474060beb3673cf5a3e39ccd3c8ad57ecd3/examples/pytorch/translation/run_translation.py#L436


P.S. While opening this issue, I also checked CLM script example and met the same problem there. https://github.com/huggingface/transformers/blob/fa322474060beb3673cf5a3e39ccd3c8ad57ecd3/examples/pytorch/language-modeling/run_clm.py#L437 

Am I wrong and miss something or it is really a problem that requires small fix?


Comments:
I should read the documentation carefully...
Replace deprecated logger.warn with warning
Author: sanchit-gandhi
Pull request: yes

From [Python docs](https://docs.python.org/3/library/logging.html#logging.Logger.warning):
_There is an obsolete method `warn` which is functionally identical to `warning`. As `warn` is deprecated, please do not use it - use `warning` instead._


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix Iterations for decoder
Author: agemagician
Pull request: yes

The current script works fine if the number of decoder layers = the number of encoder layers.
However, it will not work if the number of layers is not equal, like in t5-efficient models.

## 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?


Models:
- t5: @patrickvonplaten, @patil-suraj


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Update CLIPFeatureExtractor to convert PIL image to RGB
Author: hengkuanwee
Pull request: yes

# What does this PR do?

<!--

- Converts PIL image to `RGB` if processed by CLIPFeatureExtractor.

-->

Currently PIL images with `RGBA` format throws an error when being processed by CLIPFeatureExtractor. 

CLIPFeatureExtractor.normalize() throws the following error:
`.../sentence-transformer/lib/python3.9/site-packages/transformers/image_utils.py", line 185, in normalize
    return (image - mean) / std
ValueError: operands could not be broadcast together with shapes (4,224,224) (3,) `

The original [clip model preprocesses PIL Images](https://github.com/openai/CLIP/blob/main/clip/clip.py#L74) by converting all PIL images into `RGB` format.


## 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.

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

@patil-suraj @sgugger any idea why the `Build dev documentation / build_and_package` check failed? based on the error log, I initially suspected that master branch is out of sync (i.e. there are new commits), however, I just verified that it is up to date 🤔

 You can rebase to master to solve the failing test.

@patil-suraj I checkout my branch and ran `git rebase master`, it returns `Current branch convert-pil-image-to-rgb-clip-model is up to date.` 

You should rebase with `huggingface/transformers`, for example if your remote is called `upstream` you can run the following commands to rebase.

```bash
git fetch upstream
git rebase upstream/master
``` 

and then push.

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.

Hey @hengkuanwee , this slipped through the cracks. Do you maybe want to open new PR for this ?

hi @patil-suraj, sure i'll open a new PR for this!
Do you fine-tunde both encoder and decoder 
Author: rafikg
Pull request: no

Hi @patil-suraj

https://github.com/huggingface/transformers/blob/277fc2cc782d8c5c28ec399b1ee2fc1c6aed7b6e/examples/pytorch/summarization/run_summarization.py#L500
I am not sure why the  `input_models` does not take  `decoder_attention_mask` into account ? 

**debugging:** 

just print the `train_dataset` after this line
https://github.com/huggingface/transformers/blob/277fc2cc782d8c5c28ec399b1ee2fc1c6aed7b6e/examples/pytorch/summarization/run_summarization.py#L518

`print(train_dataset)`  gives:

```
Dataset({
    features: ['input_ids', 'attention_mask', 'labels'],
    num_rows: 2069
}) 
```
the `attention_mask` is the attention mask of the encoder 

Comments:
@rafikg Could you elaborate the question in a bit more detail? Maybe with a minimal code example that demonstrates the issue/question. In particular, could you check what are the keys in `model_inputs` at this line (when you run your example code)

https://github.com/huggingface/transformers/blob/277fc2cc782d8c5c28ec399b1ee2fc1c6aed7b6e/examples/pytorch/summarization/run_summarization.py#L501

Thank you!

@ydshieh I update the question

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 type annotations for GPTJ
Author: tmastrom
Pull request: yes

Add Python type annotations for the GPTJ Pytorch model. 


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16109). 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.
Adding type hints for BigBird pytorch
Author: tanmoyio
Pull request: yes

@Rocketknight1 

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

https://github.com/huggingface/transformers/issues/16059

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.
infer_framework_load_model function docs typo and grammar fixes
Author: jhwohlgemuth
Pull request: yes

# What does this PR do?
- Fix typo because words should not be mispelled
- Fix grammar to more properly describe the code

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/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

<!-- 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 docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15777). 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.
Simplify selection of indices in FlaxCLIPTextTransformer to support JAX model conversion tooling
Author: josephrocca
Pull request: yes

# What does this PR do?
It makes a simple change so that `FlaxCLIPModel` compatible with the `jax2tf` conversion tool, which currently doesn't support certain types of gather operations. It's explained by a JAX engineer here: https://github.com/google/jax/issues/9572#issuecomment-1047162054

## Who can review?
@patil-suraj 

Note that I haven't ran any tests. Please feel free to close this if testing is required on my part, or if there simply isn't interest in making this change at this point (`jax2tf` will eventually support a larger subset of gather operations, so it's not super high-priority in that sense).


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15762). 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.
[tests] Improve forward_signature test
Author: NielsRogge
Pull request: yes

# What does this PR do?

The `test_forward_signature` test is currently being overridden in 25 model test files, because these models don't expect `input_ids`, but rather `pixel_values` (for vision models) or `input_values` (for speech models).

This PR instead leverages the `main_input_name` to update the test in `test_modeling_common.py`, `test_modeling_tf_common.py` and `test_modeling_flax_common.py`.

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

With this approach we're losing coverage of some checks regarding `attention_mask`

@LysandreJik can you take a second look? I've improved it by including an additional attribute called `other_arg_names`.

LGTM! Thanks, can't wait to use 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.
apply torch int div to layoutlmv2
Author: ManuelFay
Pull request: yes

# What does this PR do?

Linked to #14853 (now closed - bad rebase)

@LysandreJik 

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

REALM tests seem to be failing  - doesn't seem like they should be running ?

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/master/CONTRIBUTING.md) are likely to be ignored.

@ManuelFay can you rebase with master such that we can merge your PR?

Done, and I changed the path to the custom divide function (compatible with older torch versions).  @NielsRogge 

_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.

Hi @ManuelFay, apologies, for some reason this is still not merged. Can you rebase your PR with the main branch such that we can merge it? Apologies again for asking you this a second time.

Thanks!

No problem @NielsRogge ! Here you go, rebased ;)
documentation: some minor clean up
Author: mingboiz
Pull request: yes

# What does this PR do?
This cleans up some minor documentation changes unrelated to debertav2 in the PR #15529  so I'm opening up this PR just for repo history. Please do let me know if this is alright 😄 

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [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.
https://github.com/huggingface/transformers/pull/15529
- [ ] 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.


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

Thank you!
Missing whitespaces at RuntimeError message
Author: ftnext
Pull request: no

Trailing whitespaces are missing,

https://github.com/huggingface/transformers/blob/31ec2cb2badfbdd4c1ac9c6c9b8a74e974984206/src/transformers/pipelines/__init__.py#L494-L499

so the error message is a little hard to read.

```python
>>> from transformers import pipeline
>>> pipeline(task=None, model=None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../venv/lib/python3.9/site-packages/transformers/pipelines/__init__.py", line 495, in pipeline
    raise RuntimeError(
RuntimeError: Impossible to instantiate a pipeline without either a task or a modelbeing specified.Please provide a task class or a model
```

- Python 3.9.4
- transformers 4.18.0

Comments: