noamaanMulla-03/transformers-issues huggingface dataset:
Fix a TF-T5 test
Author: ydshieh
Pull request: yes

# What does this PR do?

`test_t5_decoder_model_past_large_inputs` pass incorrect args to `create_and_check_t5_decoder_model_past_large_inputs`.
Don't know why it works so far, but I got errors when working on another PR.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Adding CVT Model
Author: AnugunjNaman
Pull request: yes

# What does this PR do?
Add CvT Model for Vision Classification

Fixes #13158


## 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.
- [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.

@NielsRogge @LysandreJik 

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

@NielsRogge can you review it and suggest any further changes.
I'm not sure how you want to modify `cls_token` part. Since modifying in `CvtStage` section (stopping the split) will change shape of hidden states (stored in all hidden states and passing of 4D shape for CNN in next layer).

I leave that part to you on how you want to change it to pass it over different classes further.

I have run the `make fix-copies` and done docstrings part. I think everything is done apart from change you wanted to make for `cls_token`.
if crf needed when do ner?  
Author: alphanlp
Pull request: no
Labels: name: Discussion

name: wontfix

If crf needed when do ner?  In BertForTokenClassification,  just Linear is used to predict tag. If not, why?

Comments:
A CRF gives better NER F1 scores in some cases, but not necessarily in all cases. In the BERT paper, no CRF is used and hence also no CRF in this repository. I'd presume the BERT authors tested both with and without CRF and found that a CRF layer gives no improvement, since using a CRF is kind of the default setting nowadays.

Issue #64 is a good reference for discussion on NER.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


This repository have showed how to add a CRF layer on transformers to get a better performance on token classification task.
https://github.com/shushanxingzhe/transformers_ner

> github.com/shushanxingzhe/transformers_ner

your code does not work
Not send successful report
Author: ydshieh
Pull request: yes

# What does this PR do?

Here we go. Bye, successful run report 😢 ~

[workflow run](https://github.com/huggingface/transformers/runs/6492878791?check_suite_focus=true)
but no report on Slack.

Comments:
There is duplication. Forgot to remove one block. Don't merge for now 🙏 

_The documentation is not available anymore as the PR was closed or merged._
no attribute ViTFeatureExtractor
Author: Pannu22
Pull request: no

Getting following error:
AttributeError: module transformers.models.vit has no attribute ViTFeatureExtractor

on calling:
`processor = TrOCRProcessor.from_pretrained("microsoft/trocr-large-printed")`

System:
Jenson AGX

Tried in RTX & it is working fine.

Installation:
`pip install git+https://github.com/huggingface/transformers`

Comments:
Installing `Pillow` to env fixed it.

Thanks for this!
Bug of the text-classification in examples
Author: EternalEep
Pull request: no
Labels: name: bug

### System Info

```shell
When I finetuned the text classification model based on the glue no trainer script, I found a bug in our script.
The URL is below:
https://github.com/huggingface/transformers/blob/main/examples/pytorch/text-classification/run_glue_no_trainer.py#L525

When we use the accelerator for multi-GPU training, the code should transfer from 
if step == len(eval_dataloader)
to 
if step == len(eval_dataloader) -1
Otherwise, it cannot work to filter the last step duplicated samples.
```


### Who can help?

_No response_

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

just run the script with a text classification using multi-GPU accelerator. The problem occurs in the last step for duplicated samples.

### Expected behavior

```shell
I think it should be fixed soon.
```


Comments:
Fix metric calculation in examples and setup tests to run on multi-gpu for no_trainer scripts
Author: muellerzr
Pull request: yes
Labels: name: Examples

name: bug

# What does this PR do?

This PR fixes all failing tests in a multi-gpu setting for all `no_trainer` example scripts. This includes an issue with when the logger was called before `Accelerator()` was created, adjusting when the conditional to add to the `samples_seen`, and adjusting `samples_seen` to use the length when the labels are just a list instead of a torch tensor.

Because the tests were rewritten to use `accelerate launch` and the new `write_basic_config`, these tests will automatically allocate themselves properly to test on multigpu, gpu, or cpu depending on what environment is available

Fixes # (issue):

Closes https://github.com/huggingface/transformers/issues/17214, https://github.com/huggingface/transformers/issues/17200


## 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?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@sgugger 


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix ci_url might be None
Author: ydshieh
Pull request: yes

# What does this PR do?

In `notification_service.py`, we have

```
    ci_url = os.environ.get("CI_COMMIT_URL")

    commit_number = ci_url.split("/")[-1]
```
but `ci_url` might be `None`, for example, for scheduled CI.

This PR moves the involved block inside 

```
    if ci_title is not None:
        assert ci_url is not None
```
(i.e. only for push CI)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
ImportError: cannot import name 'AutoProcessor' from 'transformers' 
Author: ghost
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.11.3
- Platform: macOS-10.15.7-x86_64-i386-64bit
- Python version: 3.8.13
- PyTorch version (GPU?): 1.11.0 (False)
- 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?
I am following the steps described in https://huggingface.co/docs/transformers/tasks/asr to test the AST model.

@patrickvonplaten

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

from transformers import AutoProcessor

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [9], in <cell line: 1>()
----> 1 from transformers import AutoProcessor

ImportError: cannot import name 'AutoProcessor' from 'transformers' (/Users/to125419/miniconda3/envs/s2t/lib/python3.8/site-packages/transformers/__init__.py)


### Expected behavior

```shell
I am following the steps described in https://huggingface.co/docs/transformers/tasks/asr
```


Comments:
I don't think `AutoProcessor` was already available in Transformers 4.11.

So you might need an upgrade to the latest version:

```
pip install --upgrade transformers
```

Yes you are right! Thanks for your help :)
[WIP] add MobileViT model
Author: hollance
Pull request: yes
Labels: name: New model

# What does this PR do?

Add the MobileViT model to Transformers. This is a computer vision model that combines CNNs with transformers: https://machinelearning.apple.com/research/vision-transformer

The model comes in three sizes: small, extra small, and xx-small. There are two heads: image classification and semantic segmentation. Object detection will be added later.

## 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. (Internal discussion on Slack.)
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


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

I messed up. Made a new PR instead: https://github.com/huggingface/transformers/pull/17354
Enable ONNX support for multiple-choice classification heads
Author: lewtun
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. -->

Currently, the `transformers.onnx` package doesn't support the export of models with a multiple-choice classification head, i.e. all `ModelForMultiplChoice` classes. We should enable this to provide full coverage of our current exports.

Implementing this involves:

* Adding a `multiple-choice` feature to the `FeaturesManager`
* Generating the appropriate dummy inputs
* Updating the features of all existing models which have a corresponding head

cc @michaelbenayoun 


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.
failed doctests examples for data2vec_audio, 1 failed, 4 passed
Author: artemisep
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.20.0.dev0
- Platform: Linux-5.13.0-41-generic-x86_64-with-glibc2.29
- Python version: 3.8.0
- Huggingface_hub version: 0.6.0
- PyTorch version (GPU?): 1.11.0+cu102 (False)
- Tensorflow version (GPU?): 2.9.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.4.2 (cpu)
- Jax version: 0.3.6
- JaxLib version: 0.3.5
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

@patrickvonplaten 


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

Following the instruction in https://github.com/huggingface/transformers/issues/16292 as listed below:
Make sure to run the doc example doc test locally as described in https://github.com/huggingface/transformers/tree/master/docs#for-python-files

This is marked done in https://github.com/huggingface/transformers/issues/16292, this was run as a sanity check when working with data2vec_text, https://github.com/huggingface/transformers/issues/17345 

error message:
[doctest] transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioForAudioFrameClassification.forward _______________________________________
1420           heads.
1421   
1422     Example:
1423 
1424     ```python
1425     >>> from transformers import Wav2Vec2FeatureExtractor, Data2VecAudioForAudioFrameClassification
1426     >>> from datasets import load_dataset
1427     >>> import torch
1428 
1429     >>> dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
Expected nothing
Got:
    Downloading and preparing dataset librispeech_asr/clean to /home/ruihua/.cache/huggingface/datasets/hf-internal-testing___librispeech_asr/clean/2.1.0/d3bc4c2bc2078fcde3ad0f0f635862e4c0fef78ba94c4a34c4c250a097af240b...
    Dataset librispeech_asr downloaded and prepared to /home/ruihua/.cache/huggingface/datasets/hf-internal-testing___librispeech_asr/clean/2.1.0/d3bc4c2bc2078fcde3ad0f0f635862e4c0fef78ba94c4a34c4c250a097af240b. Subsequent calls will reuse this data.

/home/ruihua/project/huggingface/tf/transformers/src/transformers/models/data2vec/modeling_data2vec_audio.py:1429: DocTestFailure



### Expected behavior

```shell
all doctest examples should pass
```


Comments:
I am closing this ticket as it is part of the doctest task, merged to https://github.com/huggingface/transformers/issues/17338
failed doctests examples for data2vec_text, 5 failed, 2 passed
Author: artemisep
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.20.0.dev0
- Platform: Linux-5.13.0-41-generic-x86_64-with-glibc2.29
- Python version: 3.8.0
- Huggingface_hub version: 0.6.0
- PyTorch version (GPU?): 1.11.0+cu102 (False)
- Tensorflow version (GPU?): 2.9.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.4.2 (cpu)
- Jax version: 0.3.6
- JaxLib version: 0.3.5
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

@patrickvonplaten 


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

Following the instruction in https://github.com/huggingface/transformers/issues/16292 as listed below:
Make sure to run the doc example doc test locally as described in https://github.com/huggingface/transformers/tree/master/docs#for-python-files

please see attachment for the 
[doctest_data2vec_text_errormsg.txt](https://github.com/huggingface/transformers/files/8721864/doctest_data2vec_text_errormsg.txt)

p.s, for sanity check, I also run the doctest sample for the following:
1. bigbird_pegasus:  all 5 tests passed
2. data2vec_audio in the same folder: 1 failed, 4 passed



### Expected behavior

```shell
all samples in doctests should pass
```


Comments:
I am closing this ticket as it is part of the doctest task, merged to https://github.com/huggingface/transformers/issues/17338
Misleading error when from_pretrained fails, says there are flax weights when there aren't
Author: nadahlberg
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.20.0.dev0
- Platform: Linux-5.14.0-1031-oem-x86_64-with-glibc2.17
- Python version: 3.8.12
- Huggingface_hub version: 0.4.0
- PyTorch version (GPU?): 1.10.0+cu102 (True)
- Tensorflow version (GPU?): 2.9.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no
```


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Tiny bug in the from_pretrained code that checks if flax weights are present.

```
from transformers import AutoModel, AutoConfig
config = AutoConfig.from_pretrained("roberta-base")
model = AutoModel.from_pretrained("some_empty_dir", config=config)
```

### Expected behavior

```shell
Should return:
EnvironmentError(
                        f"Error no file named {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME + '.index'} or "
                        f"{FLAX_WEIGHTS_NAME} found in directory {pretrained_model_name_or_path}."
                    )

Instead returns:
EnvironmentError(
                        f"Error no file named {WEIGHTS_NAME} found in directory {pretrained_model_name_or_path} but "
                        "there is a file for Flax weights. Use `from_flax=True` to load this model from those "
                        "weights."
                    )
```


Comments:
fix for 17292
Author: nadahlberg
Pull request: yes

Fixes #17292


## Before submitting
- [N/A] 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.
- [N/A] 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).
- [N/A] Did you write any new necessary tests? Tested locally


Comments:
_The documentation is not available anymore as the PR was closed or merged._
There is a minor bug in run_pretrain.py for Wav2Vec2 example
Author: ddobokki
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.18.0
- Platform: Linux-4.15.0-144-generic-x86_64-with-glibc2.27
- Python version: 3.9.12
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.7.1+cu110 (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?

@patrickvonplaten
I found a minor bug in [run_pretrain.py](https://github.com/huggingface/transformers/tree/main/examples/research_projects/wav2vec2/run_pretrain.py)

```python
from transformers.models.wav2vec2.modeling_wav2vec2 import _compute_mask_indices
.
.
.
class DataCollatorForWav2Vec2Pretraining:
...
  # sample randomly masked indices
        batch["mask_time_indices"] = _compute_mask_indices(
            (batch_size, mask_indices_seq_length),
            self.model.config.mask_time_prob,
            self.model.config.mask_time_length,
            device=batch["input_values"].device, # this!
            attention_mask=attention_mask,
            min_masks=2,
        )
        return batch
```
_compute_mask_indices take device parameter, but in [modeling_wav2vec2.py](https://github.com/huggingface/transformers/blob/main/src/transformers/models/wav2vec2/modeling_wav2vec2.py)
```python
def _compute_mask_indices(
    shape: Tuple[int, int],
    mask_prob: float,
    mask_length: int,
    attention_mask: Optional[torch.LongTensor] = None,
    min_masks: int = 0,
) -> np.ndarray:
```
device parameter does not exist, I think this hasn't been modified yet.

And thank you for the huggingface that makes good libraries!

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```python
@dataclass
class DataCollatorForWav2Vec2Pretraining:
...
        # sample randomly masked indices
        batch["mask_time_indices"] = _compute_mask_indices(
            (batch_size, mask_indices_seq_length),
            self.model.config.mask_time_prob,
            self.model.config.mask_time_length,
            device=batch["input_values"].device,
            attention_mask=attention_mask,
            min_masks=2,
        )

        return batch
```


### Expected behavior

```shell
@dataclass
class DataCollatorForWav2Vec2Pretraining:
...
        # sample randomly masked indices
        batch["mask_time_indices"] = _compute_mask_indices(
            (batch_size, mask_indices_seq_length),
            self.model.config.mask_time_prob,
            self.model.config.mask_time_length,
            attention_mask=attention_mask,
            min_masks=2,
        )

        return batch
```


Comments:
Hey @ddobokki,

good observation! Would you like to open a PR to fix it? :-)

Ok! I will 😁