noamaanMulla-03/transformers-issues huggingface dataset:
Accept batched tensor of images as input to image processor
Author: amyeroberts
Pull request: yes

# What does this PR do?

Adds functionality to `image_utils` so that a batched tensor of images can be accepted as input to the image processors. 

Fixes #21142 #14650

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Use `model_class.__name__` and compare against `XXX_MAPPING_NAMES`
Author: ydshieh
Pull request: yes

# What does this PR do?

Currently, in `tests/test_modeling_common.py`, there are a lot of condition like
```python
if model_class in get_values(MODEL_MAPPING)
```
which implies in order to get this information, all models must be able to be imported, or rely on some of our mechanism to make sure the execution won't fail the program.

In some rare case, like `natten` is installed but having a incompatible version with `torch`, we will get
```bash
E           RuntimeError: Failed to import transformers.models.dinat.modeling_dinat because of the following error (look up to see its traceback):
E           Failed to import NATTEN's CPP backend. This could be due to an invalid/incomplete install. Please uninstall NATTEN (pip uninstall natten) and re-install with the correct torch build: natten.shi-labs.com.
```
even running a single test with a model (for example, `efficientformer`) that doesn't need `natten`.

This PR changes the condition to 
```python
if model_class.__name__ in get_values(MODEL_MAPPING_NAMES)
```
which gives the same results + avoid such confusing failures + potentially reduce some overhead

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

@sgugger Is this kind of change OK for you ..? If so, I will apply the same change to other places.

The 2 failed tests are known to be flaky (for now) - Merge the PR without re-runing CI.
Fix 2 paths in the doctest list
Author: ydshieh
Pull request: yes

# What does this PR do?

doctest has 0 failures 
```
🌞 There were no failures: all 0 tests passed. The suite ran in 0h0m0s.
```
which is caused by 
```
ERROR: file or directory not found: src/transformers/models/maskformer/configuration_mask2former.py
collecting ... collected 0 items
```
😭😭😭
This PR makes the failures (if any) visible again.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
[`Speech-Encoder-Decoder`] Add `speech-encoder-decoder` to `AutoProcessor`
Author: younesbelkada
Pull request: yes

# What does this PR do?

Currently loading the correct processor for `speech-encoder-decoder` using `AutoProcessor` is broken on `main`. 
The issue and the fix is very identical as https://github.com/huggingface/transformers/pull/21299 , as a doctest was also failing. Link to failing job: https://github.com/huggingface/transformers/actions/runs/4002271138/jobs/6869333719 

cc @ydshieh @sgugger 


Comments:
Hi @younesbelkada ! Thank you for the PR(s). In my opinion, (generic) composite models like (text/vision/speech) encoder-decoder models are not meant to use `Auto` mappings, as their design is to compose any pair of models (whenever it works).

The fix should be updating the config file on the hub for these checkpoints. In this case, by adding `processor_class`, for which I have opened those Hub PR.

Makes sense! Thanks for explaining! 

_The documentation is not available anymore as the PR was closed or merged._
[`Vision-Encoder- Decoder`] Add `vision-encoder-decoder` on `AutoProcessor`
Author: younesbelkada
Pull request: yes

# What does this PR do?

Similarly as https://github.com/huggingface/transformers/pull/21319 & #21299 a doctest was failing because the correct processor was not mapped in the `AutoProcessor` mapping for `vision-encoder-decoder`

This fixes also a doctest that was failing, link to failing job: https://github.com/huggingface/transformers/actions/runs/4002271138/jobs/6869333719 

cc @ydshieh @sgugger 

Comments:
See https://github.com/huggingface/transformers/pull/21319#issuecomment-1404938821

Closing in favor of opening PRs on the Hub as described in the comment! 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_21320). All of your documentation changes will be reflected on that endpoint.
check paths in `utils/documentation_tests.txt`
Author: ydshieh
Pull request: yes

# What does this PR do?

This PR adds a new check to ensure the paths in `utils/documentation_tests.txt` are all valid, so doctest CI won't fail from the beginning.

related PR: #21314 - ~~We need to wait that PR merged before margining this one.~~ It's merged.

The effect of this PR 

<img width="800" alt="Screenshot 2023-01-26 111139" src="https://user-images.githubusercontent.com/2521628/214810581-4367c7d8-94b7-4534-94f6-b51d3582a5cb.png">


Comments:
_The documentation is not available anymore as the PR was closed or merged._
trainer get_optimizer_cls_and_kwargs doesn't seem to use optim_args
Author: zupatisc
Pull request: no

Hello,
I was reading the code for the trainer and I noticed that the optimizer arguments that get passed to the trainer with the TrainingArguments don't seem to be actually applied for any optimizers aside from AnyPrecisionAdamW, is this intended?
I don't think this question really fits into any of the templates so I didn't use them.

@sgugger 
https://github.com/huggingface/transformers/blob/4e41b87e3d13af0d1d7d3d27d101e60c33c92100/src/transformers/trainer.py#L1077


Comments:
Yes, this is intended as the regular adam kwargs have their own training argument.

Oh okay I see, is there anything speaking against using optim_args to pass kwargs to adafactor?

Adafactor in the library is deprecated an not maintained, you should rely on another implementation.

Thanks for the info but if that's the case, is there a deprecation warning somewhere for this? Because I don't recall seeing one.
In any case your info closes this issue, thank you.

We haven't officially deprecated it since we are waiting for someome to add support for another integration of it (like for AnyPrecisionAdam and the others).
[Doctest] Fix `Perceiver` doctest
Author: younesbelkada
Pull request: yes

# What does this PR do?

This PR fixes a failing doctest for `PerceiverModel`. Link to failing job: https://github.com/huggingface/transformers/actions/runs/4002271138/jobs/6869333719

With #21225 being merged, the snippet [here](https://github.com/huggingface/transformers/blob/31336dcf3f93dee19cd13c981f16982d612040d2/src/transformers/models/perceiver/modeling_perceiver.py#L796):
```python
...
model = PerceiverModel(config, input_preprocessor=preprocessor, decoder=decoder)
# you can then do a forward pass as follows:
tokenizer = PerceiverTokenizer()
```
has been modified by:
```python
...
model = PerceiverModel(config, input_preprocessor=preprocessor, decoder=decoder)
# you can then do a forward pass as follows:
tokenizer = AutoTokenizer()
```
As there is no canonical way to automatically load a tokenizer from something which is different than a path, or model id, one should load any default tokenizer by instantiating it using the child class and not using `AutoTokenizer`.

This PR reverts this change and fixes the doctest

cc @ydshieh 💯 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
ImportError: cannot import name 'pipeline' from 'transformers' (unknown location)
Author: yipy0005
Pull request: no

Hi, I created an env with conda, installed TF, then installed PyTorch, then "pip install git+https://github.com/huggingface/transformers", but when I ran 'python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I hate you'))"', it gave me the ImportError. How can I resolve this?

Comments:
I'm on MacOS btw.

Possibly duplicate of https://github.com/huggingface/transformers/issues/9939

> Possibly duplicate of https://github.com/huggingface/transformers/issues/9939

I have installed TF 2.0 right at the start. Is there a version to update to resolve this error?

So after install TF 2.0 with conda, I performed pip install --upgrade tensorflow to v2.4.1 and it works now.

The issue happens again with latest version of tensorflow and transformers.

`>>> import transformers`
`>>> from transformers import pipeline`
`Traceback (most recent call last):`
 ` File "<stdin>", line 1, in <module>`
`ImportError: cannot import name 'pipeline' from 'transformers' (unknown location)`
`>>> tensorflow.__version__`
`'2.5.0'`
`>>> transformers.__version__`
`'4.7.0'`

I had the same problem but used the false transformer:
**Initial**
`conda update -c conda-forge transformers`

**Before**
> tensorflow.__version__      # '2.3.0'
> transformers.__version__  # '2.1.1'

**Solution**
`conda install -c huggingface transformers `

**After**
> tensorflow.__version__      # '2.3.0'
> transformers.__version__  # '4.11.3'
> torch.__version__              # '1.10.0'



It is related to the solution. I have to solve it by explicit stating the version. Otherwise, it keep installing the conda-forge version.

`conda install -c huggingface transformers =4.11.3`

What is your python files name? Mine was _tokenizers_ and when I changed it to _use_tokenizers_ it works. Maybe using names like "tokenizers", "pipeline" for files not the best idea.

> What is your python files name? Mine was _tokenizers_ and when I changed it to _use_tokenizers_ it works. Maybe using names like "tokenizers", "pipeline" for files not the best idea.

I made the mistake of calling mine tokenize.py - once changed the code worked.
[i18n-KO] Translated quicktour page to Korean
Author: wonhyeongseo
Pull request: yes

# What does this PR do?

Translated the `Quicktour.mdx` file of the documentation to Korean.
Thank you in advance for your review. 

<!-- Remove if not applicable -->

Part of https://github.com/huggingface/transformers/issues/20179


## 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.
- [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).
- [ ] Did you write any new necessary tests?


## Who can review?
@sgugger, @ArthurZucker, @eunseojo may you please review this PR?

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

Thank you so much for your review @sgugger and especially @ArthurZucker for your awesome proof-read! I have commited your suggestion. Although it is a bit late, happy lunar new year everyone! 🐇 🌕 

Happy new year! 🐰
Fix M2M100 positional embedding creation for ONNX
Author: michaelbenayoun
Pull request: yes

# What does this PR do?

This PR changes the reshape step when computing the sinusoidal positional embeddings in M2M100 to make it work with ONNX.

Shape inference is incorrect before:

![Capture d’écran du 2023-01-26 18-12-40](https://user-images.githubusercontent.com/25418079/214904210-64dc5fd9-a84b-4cee-98f2-87626b721a95.png)

You can see that ONNX sets the last axis of the shape of `last_hidden_state` to be dynamic, with some auto-generated name, while it should be static.

After the fix:
![Capture d’écran du 2023-01-26 18-12-40](https://user-images.githubusercontent.com/25418079/214904432-9682bec6-aef6-47e6-a9b6-505730736dee.png)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Write inference evaluation
Author: peregilk
Pull request: no

### Feature request

This feature request is strongly inspired by T5X. They write a log every time they do an evaluation. The log is a json-lines-file that is saved in inference_eval/task-1000.jsonl. "task" is the current task, and "1000" is the checkpoint. The file is generic, and looks like this:
```json
{
  "input": {
    "inputs_pretokenized": "Hello World",
    "inputs": [###,###,###],
    "targets_pretokenized": "Hallo verden",
    "targets": [###,###,###]
  },
  "target": "Hallo verden",
  "output": "Hei verden",
  "prediction": "Hei verden"
}
```
Long inputs, like audio and images, will typically be truncated.


### Motivation

This simply makes debugging a lot easier. The jsonl-format makes it really easy to open this in another program for more thorough study. Since the same file is predicted at every step, it makes it really easy to follow the development of a single target.

### Your contribution

I would be glad to make feedback on such an implementation. I am not exactly sure where this feature should be implemented today.

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.
Little cleanup: let huggingface_hub manage token retrieval
Author: Wauplin
Pull request: yes

# What does this PR do?

Since [`huggingface_hub==0.11.0` release](https://github.com/huggingface/huggingface_hub/releases/tag/v0.11.0), `hfh` always send the stored token when making requests to the hub, unless explicitly told no (`use_auth_token=False`). Before that, `transformers` had implemented some workarounds to retrieve the cached token when `token=None` is provided by the user. This PR aims to remove those workarounds since `hfh` automatically does this part.

Note: in case of the `PushToHubMixin` class, I changed some the arguments/return value of a private methods (no need to return a token anymore). I thought it would be ok as the method is private but please let me know if you prefer that I revert this part.

## Who can review?

@sgugger


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

Yes that would be cool if a Great Depreciation is initiated! :) I can help if needed.

It seems the tests are failing with some `ModuleNotFoundError: No module named 'transformers_modules.local'` errors. Is it related to the PR? Doesn't seem to be but since it's affecting tests named `test_from_pretrained_***`, I'm asking.
In any case, if the PR looks good to you, can I let you merge it?

Those are flaky tests I need to fix :-) Merging!
Nystromformer ONNX export 
Author: whr778
Pull request: yes

# This PR implements ONNX export functionality for Nystromformer models.
In addition to running the test cases, I exported a locally built Nystromformer 2048 input sequence model to ONNX and ran prediction.  
I verified the prediction output.

Fixes # (https://github.com/huggingface/transformers/issues/21339)


## 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.
- [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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts and @NielsRogge
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


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

Hi there. The ONNX integration has moved to the [optimum library](https://github.com/huggingface/optimum) so you should open your pull request there :-)

Hi,  okay.  Should I delete this PR or fix the error and submit another PR to optimum??

Yes, you can cloes this PR. We don' accept new PRs as all the support is in optimum now.

Moving code to optimum
Add Nystromformer support to ONNX export
Author: whr778
Pull request: no

### Feature request

Add Nystromformer support to ONNX export

### Motivation

Nystromformer models are very compute inexpensive long sequence models which perform exceptionally well.

### Your contribution

I will be submitting a PR (code and docs are complete) PR is in progress.

Comments:
Moving code to optimum
Add Molecular Attention Transformer
Author: kanpuriyanawab
Pull request: no
Labels: name: New model

### Model description

I would like to add the Molecular Attention Transformer [MAT](https://github.com/ardigen/MAT) model to the Transformers

MAT has been a big leap towards development of a single neural network architecture that performs competitively across a range of molecule property prediction tasks. It unlocked a widespread use of deep learning in the drug discovery industry.  Key innovation in MAT is to augment the attention mechanism in Transformer using inter-atomic distances and the molecular graph structure. Experiments show that MAT performs competitively on a diverse set of molecular prediction tasks. 


### Open source status

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

### Provide useful links for the implementation

Link to Model Repo : [Link](https://github.com/ardigen/MAT)
Link to Paper : [Link](https://arxiv.org/abs/2002.08264)


Comments:
@sgugger Hi, would it be a valuable contribution to HuggingFace?

If you want to dive into this model, yes it would definitely be of interest!

Alright @sgugger , I'll soon put up a PR on this !

Hi @shivance! - Are you still working on this model? Since if not I would be interested in picking it up. Have a nice day! 

Sure go ahead @Bearnardd
Transformers documentation translation to Chinese (Simplified)
Author: bfss
Pull request: no

Hi!

Let's bring the documentation to all the Chinese-speaking community :)

Who would want to translate? Please follow our [TRANSLATING guide](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md). Here is a list of the files ready for translation. Let us know here if you'd like to translate any and we'll add your name to the list.

Some notes:
- Add your translations to the folder [source/zh/](https://github.com/huggingface/transformers/blob/main/docs/source/zh/)
- Register your translation in [zh/_toctree.yml](https://github.com/huggingface/transformers/blob/main/docs/source/zh/_toctree.yml); please follow the order of the [English version](https://github.com/huggingface/transformers/blob/main/docs/source/en/_toctree.yml).
- Once you're finished, open a pull request and tag this issue by including #issue-number in the description, where issue-number is the number of this issue.
- 🙋 If you'd like others to help you with the translation, you can also post in our [forums](https://discuss.huggingface.co/) or tag [@espejelomar](https://twitter.com/espejelomar) on Twitter to gain some visibility.

## Get Started section

- 

- [x]  [index.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/index.mdx). @bfss 

- [x] [quicktour.mdx](https://github.com/huggingface/transformers/blob/master/docs/source/quicktour.mdx). @bfss

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.
Patch rag tf generate
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Patches the failing tests on `main`. After merging #21324, which added support for `logits_processor` in TF framework. 

Comments:
Just need to rebase

Oups seems that this is to prehemptive! This will be for the tf timestamps PR #21334 

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