noamaanMulla-03/transformers-issues huggingface dataset:
[Community event] HugGAN sprint for training AI art with free compute
Author: NielsRogge
Pull request: no

# HugGAN sprint :art: :artist: :paintbrush:

Got GANs?

Feel free to join the [HugGAN event](https://github.com/huggingface/community-events/tree/main/huggan), which takes place virtually from April 4 - April 15th (you can join any time in between these dates). 🤗 

The goal is to train and showcase generative AI art* with free compute provided by [Paperspace](https://www.paperspace.com/).

*GANs in particular but if you're into diffusion models, go ahead ;)

## What is it about?

The main components of the HugGAN sprint consist of:

- [ ] sharing image datasets, useful for training generative models, with the community using the brand-new (and awesome) [ImageFolder](https://huggingface.co/docs/datasets/v2.0.0/en/image_process#imagefolder) and [push_to_hub](https://huggingface.co/docs/datasets/upload_dataset#upload-from-python) features. There are already 25+ datasets contributed, including famous ones such as [MetFaces](https://huggingface.co/datasets/huggan/metfaces) and [pokemon](https://huggingface.co/datasets/huggan/pokemon) :rocket:
- [ ] training GANs using [example scripts](https://github.com/huggingface/community-events/tree/main/huggan/pytorch) provided by :hugs:, or any custom model picked by you, using free compute :computer: :money_mouth_face: provided by Paperspace
- [ ] get to know how GANs work, through multiple community talks and discussions by famous AI artists (announced soon!)
- [ ] get to know the :hugs: ecosystem through [Datasets](https://huggingface.co/docs/datasets/index), [Accelerate](https://huggingface.co/docs/accelerate/index), using either PyTorch/Keras
- [ ] showcasing the magic of a GAN as a :hugs: Space, like this one: https://huggingface.co/spaces/hysts/DualStyleGAN

## What do I need to do to participate?

To participate, please follow these steps:

- [ ] fill out [this short google form](https://docs.google.com/forms/d/e/1FAIpQLSd_mpK4dYu1V-ejeTzoiIsTiMSVlZ0kYQCEoBmoa0vH-bNuag/viewform)
- [ ] create a Hugging Face Hub account [here](https://huggingface.co/join) if you haven’t already, and join the [huggan organization ](https://huggingface.co/organizations/huggan/share/bekBYwkjyeJOAlxpcYRKgjLaRcrnIOeuge)
- [ ] join our discord [here](https://discord.gg/H3bUrDPTfS) - when joining the event’s discord channel please make sure to click on the :hugs: emoji under the first message to access all relevant information.





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.
TF - Fix convnext classification example
Author: gante
Pull request: yes

# What does this PR do?

Fixes what probably was copy-paste mistake. As visible [here](https://huggingface.co/docs/transformers/main/en/model_doc/convnext#transformers.TFConvNextForImageClassification.call.example) -- the example doesn't run atm, it does with the fix.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Dataset streaming example not working
Author: HLasse
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.18.0
- Platform: Linux-5.4.173.el7-x86_64-with-glibc2.10
- Python version: 3.8.12
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.11.0a0+17540c5 (True)
- Tensorflow version (GPU?): 2.8.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.4.2 (gpu)
- Jax version: 0.3.10
- JaxLib version: 0.3.10
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
```


### 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 guide to train a model in streaming mode using the [dataset-streaming](https://github.com/huggingface/transformers/tree/main/examples/research_projects/jax-projects/dataset-streaming) directory results in the following error.

```
[11:11:16] - INFO - datasets_modules.datasets.oscar.84838bd49d2295f62008383b05620571535451d84545037bb94d6f3501651df2.oscar - generating examples from = https://s3.amazonaws.com/datasets.huggingface.co/oscar/1.0/unshuffled/deduplicated/en/en_part_480.txt.gz
Token indices sequence length is longer than the specified maximum sequence length for this model (1195 > 512). Running this sequence through the model will result in indexing errors
Traceback (most recent call last):
  File "./run_mlm_flax_stream.py", line 549, in <module>
    eval_samples = advance_iter_and_group_samples(training_iter, data_args.num_eval_samples, max_seq_length)
  File "./run_mlm_flax_stream.py", line 284, in advance_iter_and_group_samples
    samples = {k: samples[k] + tokenized_samples[k] for k in tokenized_samples.keys()}
  File "./run_mlm_flax_stream.py", line 284, in <dictcomp>
    samples = {k: samples[k] + tokenized_samples[k] for k in tokenized_samples.keys()}
TypeError: can only concatenate list (not "int") to list
```

### Expected behavior

```shell
Model training to start.
```


Comments:
Hey @HLasse, 

Note that datasets streaming is not yet official supported, but just in the `research_folder` directory. We sadly don't have the capacity to maintain these scripts. Once dataset streaming fully works, we'll upgrade those scripts to the "main" examples folder.

This issue has a suggested solution in PR #17203
Update codeparrot data preprocessing
Author: loubnabnl
Pull request: yes

This PR updates the preprocessing script of CodeParrot data (python files), we add new filters for:

- config and test files
- uncommon files (those without a mention of Python classic keyworks: `def`, `for`..) 
- unusual files (don't use the assignement `=` operator often)
- files with low ratio between number of charcaters and number of tokens after tokenization

The impact of some of these filters is analyzed in this [tweet](https://twitter.com/LoubnaBenAllal1/status/1514300881419878403?s=20&t=IkodNO5Ma3X866-Yj-LvQw).

cc @lvwerra

Comments:
_The documentation is not available anymore as the PR was closed or merged._
CodeParrot data pretokenization
Author: loubnabnl
Pull request: yes

This PR adds code for data pretokenization of CodeParrot . In fact it takes long to tokenize the data especially for small models, so having a pretokenized dataset might improve the training speed. We also fix an error in the `README.md` and `scripts/initialize_model.py` inside the codeparrot repo. 

cc @lvwerra 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Remove next sentence prediction from supported ONNX tasks
Author: lewtun
Pull request: yes

# What does this PR do?

This PR removes the `next-sentence-prediction` feature that was added in  https://github.com/huggingface/transformers/pull/17029 as part of the MobileBERT ONNX export. 

It turns out that the `forward()` method of MobileBERT and BERT includes `kwargs`, which is not supported with PyTorch's ONNX exporter. Since this feature is unlikely to be used for inference, the simplest solution is to remove it.

With this change, the ONNX slow tests all pass.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
`transformers.ViltProcessor` requires torch >= 1.10
Author: xhluca
Pull request: no

If you follow the instructions in the docs for ViltProcessor:

```python
processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-mlm")
model = ViltModel.from_pretrained("dandelin/vilt-b32-mlm")

inputs = processor(image, text, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
```

With an older version of torch, you will get:
```
TypeError: meshgrid() got an unexpected keyword argument 'indexing'
```

Maybe there should be a warning when someone tries to import ViltProcessor with an older version of torch?

Comments:
Hi,

Yes it would be great to add a warning. Are you interested in opening a PR?

@NielsRogge I created one herE :https://github.com/huggingface/transformers/pull/16756

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.
[TBD] discrepancy regarding the `tokenize` method behavior - should the unknown token be included or not
Author: SaulLu
Pull request: no

It seems that not all tokenizers have the same behavior regarding the `tokenize` method, in particular some tokenizers will show the token unknow if the token does not belong to the vocabulary and other tokenizers will show the snippet corresponding to this token unknow in the initial text.

I've created a [google colab](https://colab.research.google.com/drive/1lptT0LXsO1B9QCrOL439SHxdeFJMFe8V?usp=sharing) showing the output of the `tokenizer.tokenize(text)` method and `tokenizer.convert_ids_to_tokens(tokenizer.encode(text, add_special_tokens=False))` on several tokenizers.

I have the impression that this difference is related to the tokenization algorithm used (and therefore probably to the behavior in the `tokenizers` library).

This raises several questions:
- for what reasons is this `tokenize` method used by users.
- is it upsetting to have multiple behaviors? 
- what is the right behavior?
- if we choose to standardize this behavior, will it cause BC problems?

Comments:
Hi @SaulLu, thank you for opening an issue! IMO the `tokenize` methods should behave somewhat consistently across tokenizers - but from what I understood this may be impossible given the different tokenization methods.

My opinion on the matter is:
- We should try to have all `tokenize` methods conform
- If some cannot, then clearly document them
- If we do some changes, these will have to remain backward-compatible until v5, but we can have a v5 major version that *slightly* changes the behavior if we document each of them clearly. 

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.
Mlflowcallback fix nonetype error
Author: orieg
Pull request: yes

# What does this PR do?

This PR fix some edge case error / race conditions with the garbage collector due to the use of a `__del__` finalizer in the MLflowCallback.

In some case, the following error may occur at the end of a script execution:
```
Exception ignored in: <function MLflowCallback.__del__ at 0x7f5ad8d73c10>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/transformers/integrations.py", line 879, in __del__
TypeError: 'NoneType' object is not callable
```
This PR check that `self._ml_flow` contain the `active_run()` method. Since it's in a `__del__` finalizer, `self._ml_flow` may return as a class 'module', not `None`, despite not referencing the `mlflow` module anymore.

## 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?

@sgugger I'm wondering if a unit test should be added for integrations callback. I don't see any for other integrations tho.

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

@sgugger can this be merged or is anything else needed?

I probably was waiting for the tests to pass and it disappeared from my notifications. Thanks for the ping!
Automatically sort auto mappings
Author: sgugger
Pull request: yes

# What does this PR do?

This PR introduces a new script to automatically sort all the mappings in the auto modules alphabetically. It fixes/checks it with the usual `make style`/`make quality`/`make fixup` and a new step in the check code quality job of the CI enforces it has properly been applied.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Loading facebook/regnet-y-040 FeatureExtractor fails mysteriously unless pillow is installed
Author: eric-mitchell
Pull request: no
Labels: name: bug

### System Info

```shell
I'm running transformers installed directly from `ee393c0`.
```


### Who can help?

@NielsRogge @sgugger 

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

    import transformers
    feature_extractor = transformers.AutoFeatureExtractor.from_pretrained("facebook/regnet-y-040")

If I don't have pillow installed, the second line fails with:

    AttributeError: module transformers.models.convnext has no attribute ConvNextFeatureExtractor

If I then run `pip install pillow`, everything works as expected.

### Expected behavior

```shell
The feature extractor should be loaded successfully.
```


Comments:
Will look into this today. There should be a way to indicate the missing dependencies when the object is not found by using our dummy objects.
Better error in the Auto API when a dep is missing
Author: sgugger
Pull request: yes

# What does this PR do?

As reported in #17266, the error message when an auto API is used to load a class that can't be loaded because a dep is missing is not helpful (it actually got worse since #17250).

This PR addresses the problem by returning the associated dummy class when the right class can't be loaded, which means the subsequent call to `from_pretrained` fails with a helpful error message. For instance, the sample given in #17266 will now error with:
```
ConvNextFeatureExtractor requires the PIL library but it was not found in your environment. You can install it with pip:
`pip install pillow`
```

Fixes #17266

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

# What does this PR do?

Fix Flava CI failure
```
>       self.assertAlmostEqual(outputs.loss_info.mmm_text.item(), 1.75533199)
E       AssertionError: 1.7553329467773438 != 1.75533199 within 7 places (9.56777343796844e-07 difference)
```
Just change the argument `places` to `4`.

[Job run log](https://github.com/huggingface/transformers/runs/6416748323?check_suite_focus=true) 

Comments:
cc @apsdehal for information :-)

_The documentation is not available anymore as the PR was closed or merged._
Drop support for Python 3.6
Author: cdeepali
Pull request: no

Drop support for Python 3.6 as it is EOL

Comments:
Why deliberately drop support? If people are stuck on 3.6 for whatever reason it will be nice for them to be able to use it as long as it lasts.

Python 3.6 is EOL now.  Do we still want to retain support for it?

> Why deliberately drop support? If people are stuck on 3.6 for whatever reason it will be nice for them to be able to use it as long as it lasts.

But this will also make the development & maintenance of the library harder. Many libraries drop support for Python 3.6.

Thanks for your request! As long as there isn't a very impactful feature missing or compatibility issue with our current setup, we're unlikely to drop support for Python 3.6 just yet as we aim for maximum compatibility across versions.

Thanks @LysandreJik for your reply on this. 

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.

Python 3.6 will be dropped over the next few weeks: https://github.com/huggingface/transformers/issues/16832

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.

This has been addressed.
Error in Loading the Feature extractor 
Author: guneetsk99
Pull request: no
Labels: name: bug

### System Info

```shell
WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/transformers/commands/env.py:52: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2022-05-13 16:11:52.801587: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:39] Overriding allow_growth setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.18.0
- Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.13
- Huggingface_hub version: 0.6.0
- PyTorch version (GPU?): 1.11.0+cu113 (True)
- Tensorflow version (GPU?): 2.8.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
```


### Who can help?

@sgugger @LysandreJik 
![image](https://user-images.githubusercontent.com/43180442/168324537-ed04b1e7-f47b-41f1-8213-11759c7cb1b1.png)
I am facing this error 
I am not able to figure out how to get past it. Till yesterday I was running the same code and didnt face any errors but today when I ran it to reproduce the results this happened can you please help 

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

```

from transformers import ConvNextFeatureExtractor, ConvNextForImageClassification
from hugsvision.nnet.VisionClassifierTrainer import VisionClassifierTrainer
from transformers import AutoFeatureExtractor, SwinForImageClassification
from transformers import ViTFeatureExtractor, ViTForImageClassification
from transformers import BeitFeatureExtractor, BeitForImageClassification
from transformers import PerceiverFeatureExtractor, PerceiverForImageClassificationLearned
trainer = VisionClassifierTrainer(
	model_name   = "ViT-Model",
	train        = train,
	test         = test,
	output_dir   = "./out/",
	max_epochs   = 5,
	batch_size   = 16, # On RTX 2080 Ti
	lr	     = 0.0003,
	fp16	     = True,
	model = ConvNextForImageClassification.from_pretrained(
	    huggingface_model,
	    num_labels = 5,
	    label2id   = label2id,
	    id2label   = id2label,
		use_auth_token=True,
		ignore_mismatched_sizes=True
	),
	feature_extractor = ConvNextFeatureExtractor.from_pretrained(
		huggingface_model,
	),
)
```

### Expected behavior

```shell
I want to know why this error arose which till yesterday didnt even exist.
Just to make a note Hugsvision didnt update their code base in past one day hence I reached out to you all for help 
Thanks in advacne
```


Comments:
This is fixed by #17239
Will make a patch for PyPi.

Patched on pypi!
Add Tensorflow Swin model
Author: amyeroberts
Pull request: yes

# What does this PR do?

Adds a tensorflow implementation of the Swin architecture and associated tests. 

## 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. Will tag specific members / contributors when moved from drafts. 


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

@LysandreJik @Rocketknight1 @NielsRogge I added you as reviewers to cover the transformers, vision and tensorflow aspects of this PR. Apologies if you're not the right person to review this - and please feel free to remove yourselves or add others :)  

I think those are good choices! Reviewing now.
gpt2 model parallelization test failed
Author: lkm2835
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.20.0.dev0
- Platform: Linux-5.13.0-1015-gcp-x86_64-with-glibc2.17
- Python version: 3.8.12
- Huggingface_hub version: 0.4.0
- 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?: yes
- Using distributed or parallel set-up in script?: yes
```


### Who can help?

In main branch, ``` pytest tests/models/gpt2/test_modeling_gpt2.py ``` failed at ```test_model_parallelization```.

```
 def test_model_parallelization(self):

            ...

            # Assert that the memory use on all devices is higher than it was when loaded only on CPU
            for n in range(torch.cuda.device_count()):
>               self.assertGreater(memory_after_parallelization[n], memory_at_start[n])
E               AssertionError: 0 not greater than 0

tests/test_modeling_common.py:2069: AssertionError
```

I'm implementing model parallelization on OPT, but there is the same problem. (https://github.com/huggingface/transformers/pull/17245)

But, it works on trainer.

@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

``` pytest tests/models/gpt2/test_modeling_gpt2.py ```

### Expected behavior

```shell
memory_at_start : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
memory_after_parallelization : [179, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 0, 0, 0, 0]

Number of my gpu devices is 16. but len(self.h) at gpt2 is 12.
```


Comments: