noamaanMulla-03/transformers-issues huggingface dataset:
Fix typo
Author: julianpollmann
Pull request: yes

# Fix typo in docs

## 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?
- [ ] 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.

<!-- 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_17118). 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.
Add model UniTE to huggingface repository.
Author: wanyu2018umac
Pull request: yes

# What does this PR do?

This PR adds model UniTE to the repository of Huggingface.
Paper: [UniTE: Unified Translation Evaluation](https://arxiv.org/abs/2204.13346).
Former discussion is [here](https://github.com/huggingface/transformers/issues/16366).

## Who can review?

@LysandreJik
Anyone in the community is free to review the PR once the tests have passed.


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

Thank you for your PR. If I understand correctly, this adds a new type of sequence classification on XLMRoberta, but this won't work at all inside Transformers, since you are not following the API of other models:
- the model should return a `ModelOuput` 
- it should accept the same arguments as other sequence classification models and return the same kind of outputs otherwise it just won't work with the `Trainer` or the `pipeline` function.

Also please follow the general guidelines for a [new model addition](https://huggingface.co/docs/transformers/add_new_model).



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 FlaxConvNext
Author: DarshanDeshpande
Pull request: yes

# What does this PR do?
Adds a Flax ConvNext model to transformers.

## Who can review?
This is currently an in-progress PR as discussed with @patil-suraj 
TODO: Fix docstrings, ensure proper parameter name mapping for inter-framework weight conversion and write tests

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15977). 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.

Hey @DarshanDeshpande ! Sorry to only reply here now. This slipped through the cracks. LMK if you are still interested to add this model in Flax :)

Hey @patil-suraj, I am still interested in adding the Flax ConvNeXt but I will need some guidance with the TODOs mentioned in the first commit.

I will go through the PR tomorrow and do an initial review.

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.
FX function refactor
Author: michaelbenayoun
Pull request: yes

# What does this PR do?

This PR just refactors some pieces of code that are useful in `symbolic_trace` so that they can be used as standalone functions, and in other libraries, for instance [here](https://github.com/huggingface/optimum/pull/216/files#diff-7b6db6e19d4646fd3712298b1abef6ab3ba778d9a9c411aed1d12599ec25725fR164). 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17625). All of your documentation changes will be reflected on that endpoint.
[LongT5] disable model parallel test
Author: patil-suraj
Pull request: yes

# What does this PR do?

LongT5 doesn't implement the old model parallel logic. This PR disables the model parallel tests for longt5. 

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

> Thank you for the quick action, @patil-suraj ❤️
> 
> Just to know: we no longer add `parallelize` to new models, right, like what @patrickvonplaten said it's outdated?

Yes, because now any model can be parallelized using the sharded checkpoint and accelerate utils that Sylvain added. cf https://github.com/huggingface/transformers/pull/17341
fix tolerance for a bloom slow test
Author: younesbelkada
Pull request: yes

# What does this PR do?

FIxes a slow test that was ignored in the previous PR
- The number was not exactly equal due to some torch version mismatch when I did the tests on the DGX (when the test was designed) -> Note that the results of some operations are not similar across torch version compiled differently 
- Just changed the tolerance and seems to work fine
 cc @ydshieh 


Comments:
👍 Never assert equal float -> the result will be float too 😄 

_The documentation is not available anymore as the PR was closed or merged._
mBART generate random strings in end of sentence
Author: ZeguanXiao
Pull request: no
Labels: name: bug

### System Info

```shell
transformers==4.19.2
```


### Who can help?

@patil-suraj@patrickvonplaten, @Narsil, @gante

### 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

Since this happens to my personal project and the code is too custom, I just past the results and ```generete```call. As below show, sometimes mBART don't stop generating sentence properly but generate some strange tokens.
       
 ```
if "25" in self.hparams.model_name_or_path:
      generated_tokens = self.model.generate(input_ids=batch["input_ids"],
                                             attention_mask=batch["attention_mask"],
                                             decoder_start_token_id=self.tokenizer.lang_code_to_id[self.hparams.tgt_lang],
                                             do_sample=True,
                                             temperature=self.hparams.temperature,
                                             num_return_sequences=self.hparams.n_hypothesis,
                                             max_length=MAX_LENGTH)
  else:
      generated_tokens = self.model.generate(input_ids=batch["input_ids"],
                                             attention_mask=batch["attention_mask"],
                                             forced_bos_token_id=self.tokenizer.lang_code_to_id[self.hparams.tgt_lang],
                                             do_sample=True,
                                             temperature=self.hparams.temperature,
                                             num_return_sequences=self.hparams.n_hypothesis,
                                             max_length=MAX_LENGTH)
```
<img width="867" alt="屏幕快照 2022-06-15 上午10 40 25" src="https://user-images.githubusercontent.com/38279341/173725168-c867fc87-6f0f-4205-a76e-bf70b5a946d6.png">
<img width="412" alt="屏幕快照 2022-06-15 上午10 44 52" src="https://user-images.githubusercontent.com/38279341/173725722-271fb4d4-ccdc-47b0-be5c-31296c596fb2.png">



### Expected behavior

```shell
mBART all ways generate valid sentence.
```


Comments:
resize_token_embeddings in BartForConditionalGeneration doesn't change lm_head size
Author: cyr0930
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.19.2
- Platform: Windows-10-10.0.19041-SP0
- Python version: 3.7.6
- Huggingface_hub version: 0.1.2
- PyTorch version (GPU?): 1.11.0+cu113 (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?: Y
- Using distributed or parallel set-up in script?: N
```


### Who can help?

@patil-suraj

### 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. Call resize_token_embeddings with different vocab size

### Expected behavior

```shell
When I call resize_token_embeddings, it resizes embedding but not lm_head even though embedding and lm_head are tied.
Is it intended or a bug?
Or am I using resize_token_embeddings method wrongly?
```


Comments:
I am wrong about this issue.
It works fine.
Transformer Vit-MAE hard coded image channels
Author: EmreTaha
Pull request: no

### Feature request

Although the config file for the model accepts number of input channels, the class methods patchify and unpatchify use hard coded 3 channel image input. It should use num_channels argument of the config. https://github.com/huggingface/transformers/blob/a727db62f4f4e5cb15020fa5efa86ae559324616/src/transformers/models/vit_mae/modeling_vit_mae.py#L899

### Motivation

With this feature, VIT MAE model will be able to run on gray scale images as well

### Your contribution

I already fixed it in my code, but I haven't tested it thoroughly

Comments:
Hi,

This has already been asked in #17473. I'll review the related PR #17491
[ViT_MAE] fix num of channels in `patchify` and `unpatchify`
Author: johnnv1
Pull request: yes

# What does this PR do?
Fix the hard-coded number of channels in `patchify` and `unpatchify` methods.

Fixes #17473 

## Who can review?
@NielsRogge 


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

@NielsRogge I didn't find what is breaking the doc now

@NielsRogge , can you re-run the gh action? looks like something interrupted it

Hi,

I've created PR #17710 that fixes some more things, like the variable names and docstrings.
fix image type DETR feature extraction for panoptic segmentation
Author: johnnv1
Pull request: yes
Labels: name: Feature extractors

# What does this PR do?

The __call__ function of the DETR, expects an object with a `shape` when `pad_and_return_pixel_mask=True`
If try to use the extract feature with `do_resize=False` and `do_normalize=False` will crash on https://github.com/huggingface/transformers/blob/69233cf03be5fbce0492f3997e139c4d05499e27/src/transformers/models/detr/feature_extraction_detr.py#L584
because if pass the image as PIL format will need to convert this to an object with shape. And the conversion to Numpy array is done on this PR, to fix at `prepare_coco_panoptic`.

## 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.
- [ ] 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?
@NielsRogge 
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_16715). 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.
ViTFeatureExtractor PyTorch Batch problem
Author: marcomameli1992
Pull request: no
Labels: name: Feature extractors

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.15.0
- Platform: macOS
- Python version: 3.8
- PyTorch version (GPU?): CPU
- Tensorflow version (GPU?):
- Using GPU in script?: no
- Using distributed or parallel set-up in script?:

### Who can help

Models: ViTFeaturesExtractor

Model hub: google/vit-base-patch16-224-in21k

I'm trying to use this model with a Batch of images but every time I'm getting the error: "TypeError: Cannot handle this data type: (1, 1, 427, 320), |u1". If I do not use a Dataloader for the images It works well. If I not adding a dimension to the tensor it works well but when I use the batch size in the position 0 of a torch tensor it does not work. With some debugging inxpection I have found the fact that this string of code return False : `is_batched = bool(
            isinstance(images, (list, tuple))
            and (isinstance(images[0], (Image.Image, np.ndarray)) or is_torch_tensor(images[0]))
        )`

Bu If I'm using the is_torch_tensor method it give me that the images passed is a tensor of images but it is not.a list, I think that the check has to be changed like this: 
`is_batched = bool(
            (isinstance(images, (list, tuple))
            and (isinstance(images[0], (Image.Image, np.ndarray))) or is_torch_tensor(images[0]))
        )`

Whit this changes the model works.

Comments:
Hi,

Currently the feature extractors only accept a list of individual PyTorch tensors/Numpy arrays/PIL images in case you want to preprocess a batch of images. One cannot provide a batch of images as a single PyTorch tensor to the feature extractor. 

However, there's a feature request to add this (see #14650).

Note that feature extractors use PIL to resize images, so it's most efficient to pass a list of PIL images.

Thank you for your answer but in this way I can't use the GPU for training a model that uses the ViT and is moved on the GPU because every time I give it a list of Cuda tensor it says it is not possible and It suggest me to use Tensor.cpu() at the same time if I send a CPU tensor and the complete model is on the GPU It gives me the error that I have to use the same type of tensor

Have you taken a look at the [notebooks](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer) to fine-tune ViT?

I proposed a way to use DataLoader in #15055

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.
Revert "Skip tests relying on RepoNotFound errors until bug is fixed"
Author: sgugger
Pull request: yes

Reverts huggingface/transformers#17646

Test will fail for now, but one day, a hero will fix them and we can click the "Relaunch workflow from failed" button to see them passing, and we will be able to be merge this PR.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17647). All of your documentation changes will be reflected on that endpoint.
Change push CI to run on workflow_run event
Author: ydshieh
Pull request: yes

# What does this PR do?

The attempt in #17369 (to make commit history status checks less noisy) unfortunately has no effect.
After a discussion in [this comment](https://github.com/huggingface/transformers/pull/17369#issuecomment-1153846717), this PR changes push CI to be triggered by a `on: workflow_run` event.

Note the change only takes effect once this PR is merged into `main`, as mentioned in the doc. of [workflow_run](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run).

The result would be like in [accelerate](https://github.com/huggingface/accelerate), where the jobs in `on-merge.yml` won't be shown, and the workflow run page look like [this](https://github.com/huggingface/accelerate/actions/workflows/on-merge.yml).

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

@sgugger I merged this PR, you can check on the commit history page

[Change push CI to run on workflow_run event](https://github.com/huggingface/transformers/commits/main)

Hope you ❤️  it!

Amazing, thanks a lot!

I am sorry to bother you again ...
Documentation: RemBERT fixes
Author: stefan-it
Pull request: yes

Hi,

this PR introduces some fixes for the RemBERT documentation:

Python Codeblock fix for the configuration class. It is currently broken:

![image](https://user-images.githubusercontent.com/20651387/172928831-444c9f6b-2df7-404d-a4cb-a6d5b628fe76.png)

And now fixed with this PR:

![image](https://user-images.githubusercontent.com/20651387/172931066-ab5ca258-b334-4154-befd-01b678e041b9.png)

See [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17641/en/model_doc/rembert#transformers.RemBertConfig.example) for live demo.

Additionally, the model identifier `rembert` is not working, because the model is stored under the `google` namespace. This fix was done passing `google/rembert` to the `checkpoint` argument of the `add_code_sample_docstrings` decorator. This was reported in #17147.

Old [model identifier example](https://huggingface.co/docs/transformers/v4.19.3/en/model_doc/rembert#transformers.RemBertModel.forward.example) vs. [new working model identifier example](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17641/en/model_doc/rembert#transformers.RemBertModel.forward.example).

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

Good catch!

Thanks for fixing @stefan-it
Revert "Change push CI to run on workflow_run event"
Author: ydshieh
Pull request: yes

Reverts huggingface/transformers#17692

Really sorry, but the `notification_service.py` has error

```
Traceback (most recent call last):
  File "utils/notification_service.py", line 766, in <module>
    ci_author = ci_details["author"]["login"]
KeyError: 'author'
```

as the GH event is no longer coupled with a commit, and we lose some information about commit/author.
I need to change more things.

(On my own repo for testing, there is no `notification_service.py`. And this change of `workflow_run` can only be verified when being merged to `main`)

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

merged to avoid further test failures
CLI: Add flag to push TF weights directly into main
Author: gante
Pull request: yes

# What does this PR do?

Adds the `--push` flag to the `pt-to-tf` CLI, to enabling pushing straight to main (assuming the user has the right permissions).

Why am I adding this flag? A few users mentioned that they would be interested in having TF weights silently pushed straight into their repos. With this flag, I can start building a local midnight cronjob to automate the conversions (starting with pushes for users that requested it, then PR opening on users interested in PRs, then 1 PR per user if not whitelisted), which can eventually be moved into a separate machine to continuously feed the TF ecosystem 🔥 

Comments:
Yes yes yes! Maybe users could just set a flag, like "auto-convert my weights" and then we could have a machine that tracks their repos, looks for weights files that have changed and auto-updates versions for the other frameworks?

_The documentation is not available anymore as the PR was closed or merged._
[tests] workaround for relative dataset path
Author: stas00
Pull request: yes

`datasets==2.3.1` introduced a bug where it fails to load a dataset via a path that contains `..`. 

This PR works around it by avoiding this situation in the tests.

@sgugger, @ydshieh 

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

the just released `datasets==2.3.2` fixed the bug, so closing this PR.
normalize keys_to_ignore
Author: stas00
Pull request: yes

as discussed at https://github.com/huggingface/transformers/issues/16719#issuecomment-1156599137 this PR normalizes `_keys_to_ignore_on*` to not backslash on dot, unless it's an actual regex with regex patterns - this is just for consistency and easier troubleshooting. As sometimes it's unclear if `\` is needed or not when different modeling files use different styles.

@sgugger 


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