noamaanMulla-03/transformers-issues huggingface dataset:
fix default num_attention_heads in segformer  doc
Author: JunMa11
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # [16605](https://github.com/huggingface/transformers/issues/16605)


## Before submitting
- [X] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).



## Who can review?

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._
don't load state_dict twice when using low_cpu_mem_usage in from_pretrained
Author: patil-suraj
Pull request: yes

# What does this PR do?

In `from_pretrained` the `state_dict` is loaded twice when `low_cpu_mem_usage` is `True`,  which is not required since the `state_dict` is already loaded before as we can here.
https://github.com/huggingface/transformers/blob/21decb7731e998d3d208ec33e5b249b0a84c0a02/src/transformers/modeling_utils.py#L1795-L1797

So, it's fine to remove it there because when is_sharded=False, the state_dict is loaded at line 1797

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Use CLIP model config to set some kwargs for components
Author: ydshieh
Pull request: yes

# What does this PR do?

In `CLIPModel`, set `output_attentions` and `output_hidden_states` using `CLIPModel.config` if these values are specified in the configuration + not specified in the arguments.

(currently, these operations are done in its vision & text components separately, and cause a WIP CLIP PT/TF equivalence test failing - #16557)

## Details

Currently, `CLIPModel` uses its 2 components' (`vision_model` and `text_model`) configurations to perform things like

(here self is `CLIPVisionTransformer` or `CLIPTextTransformer`)
```python
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
```

If `output_attentions`/`output_hidden_states` are not passed to `CLIPModel.forward` at this line

https://github.com/huggingface/transformers/blob/9fd5e6bbe605941b707b0e1aa223a5c51c183550/src/transformers/models/clip/modeling_clip.py#L966-L967

but `CLIPModel.config` has these values set, `CLIPModel.config.output_attentions` and `CLIPModel.config.output_hidden_states` won't have any effect. This case happens here
https://github.com/huggingface/transformers/blob/9fd5e6bbe605941b707b0e1aa223a5c51c183550/tests/test_modeling_tf_common.py#L544-L547

Therefore, **CLIP PT/TF equivalence test won't returns hidden_states/attentions for the PT model.**

In TF, 

https://github.com/huggingface/transformers/blob/b33ab4eb59f3baa0108d494695bc09b4688960a7/src/transformers/modeling_tf_utils.py#L393

will use `config` to set the kwargs at the `CLIPModel` level. These kwargs are passed to the 2 components, and **CLIP PT/TF equivalence test  returns hidden_states/attentions for the TF model.**


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

cc @gante (just for information) since he is recently working on `unpack_inputs` & `input_processing` in TF
[FlaxSpeechEncoderDecoderModel] More Rigorous PT-Flax Equivalence Tests
Author: sanchit-gandhi
Pull request: yes

Adds more rigorous PyTorch-Flax equivalence tests for the FlaxSpeechEncoderDecoderModel. Namely, this PR adds equivalence tests for the intermediate hidden-states. 

## 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).
- [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.


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix TFTransfoXLLMHeadModel outputs
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix the outputs of `TFTransfoXLLMHeadModel` (in the case without `labels`) - current TF returns `softmax_output` while PT returns `prediction_scores`:

- Current PT

    https://github.com/huggingface/transformers/blob/6f9d8dc1567889b073b91059c9b19e9a6813abfa/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1119
    and

    https://github.com/huggingface/transformers/blob/6f9d8dc1567889b073b91059c9b19e9a6813abfa/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1138-L1140

- Current TF

    https://github.com/huggingface/transformers/blob/6f9d8dc1567889b073b91059c9b19e9a6813abfa/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L1005-L1006


## Remarks:

  - The case with `labels` is much more complicated - to be addressed in the future.
  - The current PT/TF equivalence test has a bit flaw and doesn't detect this issue. A WIP PR #16557 is on its way (with other enhancements)!

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Added Annotations for PyTorch models
Author: anmolsjoshi
Pull request: yes

# What does this PR do?

Adds annotations as described in https://github.com/huggingface/transformers/issues/16059:
* Updated type annotations for CTRL (PT), RAG(PT)
* added type annotations for FSMT(PT), LED(PT), M2M(PT), MPNet(PT) , Nystromformer(PT), OpenAI(PT)


## 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?

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._

@sgugger not sure why the tests are failing. I'm pretty sure they aren't related to added annotations

Thanks! We just need a last `make style` on your branch for the code quality check :-)
Fix doc example
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR fixes the doc example of `xxxForSequenceClassification` models. I wonder how this test passes currently, cause for me it returned an error as the labels are of shape `(batch_size, num_labels)` but the `problem_type` wasn't set to "multi_label_classification".


Comments:
_The documentation is not available anymore as the PR was closed or merged._
[megatron-bert-uncased-345m] fix conversion
Author: stas00
Pull request: yes

Fixes: https://github.com/huggingface/transformers/issues/16638

The original conversion script made an assumption that all released `megatron-bert-*-345m` checkpoints had the same vocab, but https://huggingface.co/nvidia/megatron-bert-cased-345m/blob/main/vocab.txt and https://huggingface.co/nvidia/megatron-bert-uncased-345m/blob/main/vocab.txt are quite different.

This PR sets `config.vocab_size` to the actual size of one of the params of vocab dimension.

I tested that both checkpoints mentioned above convert and load correctly:

```
python src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron-bert-cased-345m/checkpoint.zip
python -c 'from transformers import MegatronBertForMaskedLM; MegatronBertForMaskedLM.from_pretrained("megatron-bert-cased-345m")'

python src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron-bert-uncased-345m/checkpoint.zip
python -c 'from transformers import MegatronBertForMaskedLM; MegatronBertForMaskedLM.from_pretrained("megatron-bert-uncased-345m")'
```
both succeed. 

Before this PR only the former worked, and the 2nd failed with:
```
RuntimeError: Error(s) in loading state_dict for MegatronBertForMaskedLM:
	size mismatch for cls.predictions.bias: copying a param with shape torch.Size([30592]) from checkpoint, the shape in current model is torch.Size([29056])
```
29056 is the vocab size of `megatron-bert-cased-345m`

@LysandreJik, @sgugger 


Comments:
_The documentation is not available anymore as the PR was closed or merged._
run_glue_no_trainer.py
Author: backurs
Pull request: no

Line 428 in "text-classification/run_glue_no_trainer.py":

if step % args.gradient_accumulation_steps == 0 or step == len(train_dataloader) - 1:

replace it with:

if (step + 1) % args.gradient_accumulation_steps == 0 or step == len(train_dataloader) - 1:

Comments:
Hi @backurs -- would you like to open a PR with the change? :)

Hi Joao,
I get this error when trying to push my branch to the origin:
[image: image.png]
How do I fix this problem?
Thanks,
Arturs

On Mon, Feb 28, 2022 at 5:38 AM Joao Gante ***@***.***> wrote:

> Hi @backurs <https://github.com/backurs> -- would you like to open a PR
> with the change? :)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/15801#issuecomment-1054118985>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AODENVAOBFJST45ZDDNIAXLU5NGDNANCNFSM5PFKGZ7A>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>


Hi @backurs  -- there was a problem with the image attachment (possibly because your comment was an email reply). Can you resubmit it through a GitHub comment, please?

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.
Remove parent/child tests in auto model tests
Author: sgugger
Pull request: yes

# What does this PR do?

This PR removes the tests that checks whether models/configs/tokenizers are sorted in the auto mappings such that children classes are before parent classes. While it may have been necessary in the pasts for the `AutoXxx` APIs to work, this is not longer the case and this actually makes it harder on contributors to add new models.

Also, in the future we could have a script like isort that enforces all those auto-mappings are alphabetically sorted.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16653). All of your documentation changes will be reflected on that endpoint.
Add tests for no_trainer + fixes
Author: muellerzr
Pull request: yes

# New tests for the `no_trainer` scripts

## What does this add?

- Adds in test cases for each of the `no_trainer` scripts, mocking how the Transformers counterparts work
- Fixes a small variety of bugs inside the `no_trainer` scripts, discovered while writing these tests
- Introduces the ability to write a json file at the end of training, so that tests can be performed, similar to the Transformers tests

Comments:
Updated _load_pretrained_model_low_mem to check if keys are in the state_dict
Author: FrancescoSaverioZuppichini
Pull request: yes

# What does this PR do?

This PR checks if any key is in the `state_dict` before attempting to load it. If we have multiple checkpoints, not all keys are in every checkpoint.

TODO
- [ ] tests


Comments:
I am wondering what is the correct place to add a test for this function

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

Your plan works for me, Sylvain. I will work on the low mem test then today.
RegNet
Author: FrancescoSaverioZuppichini
Pull request: yes

# What does this PR do?
This WIP PR adds [RegNet](https://arxiv.org/abs/2003.13678). 

Currently, the model can be used as follows

```python
from transformers import  RegNetConfig, RegNetForImageClassification
import requests
from io import BytesIO
res = requests.get('https://github.com/huggingface/transformers/blob/master/tests/fixtures/tests_samples/COCO/000000039769.png?raw=true')
image = Image.open(BytesIO(res.content))

feature_extractor = AutoFeatureExtractor.from_pretrained("zuppif/regnet-y-040")
model = RegNetForImageClassification.from_pretrained("zuppif/regnet-y-040").eval()

inputs = feature_extractor(image, return_tensors="pt")
outputs = model(**inputs)
print(model.config.id2label[torch.argmax(outputs.logits).item()])
# tiger cat
```

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

Updated the codebase to use `config` when is possible. I had to update `ResNetModel` as well to make `make fixup` happy :)

Conversion script for the 10B regnet model added + needed changes inside `PretrainedModel._load_pretrained_model_low_mem` 

Thanks to all reviewers, I've rebased and updated the code accordingly
Add type hints for XLM TensorFlow
Author: elusenji
Pull request: yes

# What does this PR do?
This PR adds type hints to the XLM model for TensorFlow.

Models:

- albert, bert, xlm: @LysandreJik



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16223). All of your documentation changes will be reflected on that endpoint.
Add TAPEX
Author: NielsRogge
Pull request: yes

# What does this PR do?

Remember [TAPAS](https://huggingface.co/docs/transformers/model_doc/tapas), the table QA model by Google AI? Microsoft has now released TAPEX, a seq2seq model that outperforms TAPAS and is actually much simpler: table QA is just treated as a seq2seq problem.

As the weights can be directly loaded into a BART model, this PR only implements `TapexTokenizer`, which can be used to prepare tables and corresponding texts for the model.

This PR also adds 3 scripts that showcase how to fine-tune TAPEX on 3 important benchmarks: WikiSQL and WTQ for table question answering and TabFact for table fact verification.

Kudos to @SivilTaram (the original author) for improving my initial `TapexTokenizer` implementation, as well as adding the 3 fine-tuning scripts.

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

`make fixup` is complaining:

```
examples/research_projects/tapex/run_wikitablequestions_with_tapex.py:50:1: F401 'wikisql_utils._TYPE_CONVERTER' imported but unused
examples/research_projects/tapex/run_wikitablequestions_with_tapex.py:50:1: F401 'wikisql_utils.retrieve_wikisql_query_answer_tapas' imported but unused
```

However, these functions are used in the script, so I can't remove these imports.

@NielsRogge Thanks for your huge effort! I personally think these two warnings are correct since these two imports are only used in `run_wikisql_with_tapex.py` instead of `run_wikitablequestions_with_tapex.py` (the hint message). I think we can remove them.

> examples/research_projects/tapex/run_wikitablequestions_with_tapex.py:50:1: F401 'wikisql_utils._TYPE_CONVERTER' imported but unused
examples/research_projects/tapex/run_wikitablequestions_with_tapex.py:50:1: F401 'wikisql_utils.retrieve_wikisql_query_answer_tapas' imported but unused


@sgugger I've addressed all comments.

All models on the hub do work with the Auto API, can you elaborate? TAPEX is also added to `configuration_auto.py` and `modeling_auto.py`.
Update Support image on README.md
Author: BritneyMuller
Pull request: yes

# What does this PR do?

Updates the Support image linking to our [Expert Acceleration Program Page](https://huggingface.co/support). 

The Marketing + Monetization Team felt this image deserved a refresh to better highlight the incredible Machine Learning Experts at Hugging Face. In addition, we hope this helps drive additional EAP awareness among our brilliant community members in an effort to better support their ML work/roadmaps.


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

whenever possible you should compress images using https://tinypng.com/

Here you'd be saving 83% for instance:

compressed image:
![new-support (1)](https://user-images.githubusercontent.com/326577/161844780-a2fa3921-ef5e-4293-b05d-8231bbc38730.png)

Other than that, looks good to me! cc'ing @gary149 in case he has feedback on the design

> Other than that, looks good to me! cc'ing @gary149 in case he has feedback on the design

Looks ok to me, but the logo is distorted and maybe the image should be vertically smaller to take less space on the readme?

The logo shouldn't be distorted. Have tested this and the original image was verified/improved by our graphic designer, Bibi. @feconroses if you have any other thoughts?

@gary149 could you share additional details/screenshots to help us address any distortions? 

Looks good to me! 

i think what @gary149 means is the logo is not the usual aspect ratio, it's "flatter". (let me invite Bibi to GitHub BTW)

Hi! Bibi here. I'll have a look at the issue and resolve it

Ok for me.

you should tweet about it @BritneyMuller!
add vit tf doctest with @add_code_sample_docstrings
Author: johko
Pull request: yes

# What does this PR do?

Creates doctest for TF version of ViT. It is a cleaner version of PR #16462 which had a messed up history.

Fixes # (issue)


## 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?

@ydshieh 

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

LGTM, thank you @johko !

I ran it locally and the the doctests passed!

@sgugger Could you have a final look too?
bert: properly mention deprecation of TF2 conversion script
Author: stefan-it
Pull request: yes

Hi,

after training some BERT models with the TF2 implementation from the TF models repo, I just made the following observations:

The training code was deprecated a while ago, and now lives under the `legacy` namespace. I have trained models with this "legacy" implementation but the TF2 conversion script is no longer working.

I did some debugging, trained a few models and found out that the latest working version is v2.3.

For that reason, I have just updated the description in the TF2 conversion script.

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

Hi @LysandreJik , unfortunately, there's no working example code for pre-training in the TF models repo yet (I did some experiments, but I was not able to get a working setup). However, there's a Roformer code (https://github.com/tensorflow/models/tree/master/official/projects/roformer) available and training is working.

Sounds good, let's merge the PR like this then. Thanks for your contribution!
Fix QA sample
Author: ydshieh
Pull request: yes

# What does this PR do?

Try to address the issue about `PT_QUESTION_ANSWERING_SAMPLE` discussed in the following 2 comments:

https://github.com/huggingface/transformers/pull/16523#issuecomment-1088635272

https://github.com/huggingface/transformers/pull/16523#issuecomment-1090346578

Comments:
@patrickvonplaten @sgugger  

I would like to have a feedback to see if this is in good direction.

@sgugger `make style` will break the line into 2 lines. But when replacing the `qa_target_start_index` and `qa_target_end_index` by `14` & `15`, it actually fits in one line. Should I use a shorter name like `qa_target_start_idx` or `qa_start_index` for example?

cc @vumichien and @bhadreshpsavani to keep them updated

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

I should do the same for `TF_QUESTION_ANSWERING_SAMPLE`. Currently just to have some feedbacks from you if any :-)

I also changed `TF_QUESTION_ANSWERING_SAMPLE`. 

Ran locally for `Roberta` and `TFRoberta`, and their doctest pass.

Ready for @sgugger to give a final look :-)

@vumichien @bhadreshpsavani 

Could you pull the latest change into the master/main branch of your local clone, rebase your working branch for this sprint, and check if the QA doc example can now pass the doctest, please? Thanks a lot!