More control over TQDM when using map/filter with multiple processes
{'login': 'BramVanroy', 'id': 2779410, 'node_id': 'MDQ6VXNlcjI3Nzk0MTA=', 'avatar_url': 'https://avatars.githubusercontent.com/u/2779410?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/BramVanroy', 'html_url': 'https://github.com/BramVanroy', 'followers_url': 'https://api.github.com/users/BramVanroy/followers', 'following_url': 'https://api.github.com/users/BramVanroy/following{/other_user}', 'gists_url': 'https://api.github.com/users/BramVanroy/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/BramVanroy/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/BramVanroy/subscriptions', 'organizations_url': 'https://api.github.com/users/BramVanroy/orgs', 'repos_url': 'https://api.github.com/users/BramVanroy/repos', 'events_url': 'https://api.github.com/users/BramVanroy/events{/privacy}', 'received_events_url': 'https://api.github.com/users/BramVanroy/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892871, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODcx', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/enhancement', 'name': 'enhancement', 'color': 'a2eeef', 'default': True, 'description': 'New feature or request'}]
[]
['Hi,\r\n\r\nIt\'s hard to provide an API that would cover all use-cases with tqdm in this project.\r\n\r\nHowever, you can make it work by defining a custom decorator (a bit hacky tho) as follows:\r\n```python\r\nimport datasets\r\n\r\ndef progress_only_on_rank_0(func):\r\n    def wrapper(*args, **kwargs):\r\n        rank = kwargs.get("rank")\r\n        disable_tqdm = kwargs.get("disable_tqdm", False)\r\n        disable_tqdm = True if rank is not None and rank > 0 else disable_tqdm\r\n        kwargs["disable_tqdm"] = disable_tqdm\r\n        return func(*args, **kwargs)\r\n    return wrapper\r\n    \r\ndatasets.Dataset._map_single = progress_only_on_rank_0(datasets.Dataset._map_single)\r\n``` \r\n\r\nEDIT: Ups, closed by accident.\r\n\r\nThanks for the provided links. `Trainer` requires this for training in multi-node distributed setting. However, `Dataset.map` doesn\'t support that yet.\r\n\r\nDo you have an API for this in mind? `Dataset.map` is already bloated with the arguments, so IMO it\'s not a good idea to add a new arg there.\r\n\r\n'
 'Inspiration may be found at `transformers`.\r\n\r\nhttps://github.com/huggingface/transformers/blob/4a394cf53f05e73ab9bbb4b179a40236a5ffe45a/src/transformers/trainer.py#L1231-L1233\r\n\r\nTo get unique IDs for each worker, see https://stackoverflow.com/a/10192611/1150683']
It would help with the clutter in my terminal if tqdm is only shown for rank 0 when using `num_proces>0` in the map and filter methods of datasets.

```python
dataset.map(lambda examples: tokenize(examples["text"]), batched=True, num_proc=6)
```

The above snippet leads to a lot of TQDM bars and depending on your terminal, these will not overwrite but keep pushing each other down.

```
 #0:   0%|          | 0/13 [00:00<?, ?ba/s]
 #1:   0%|          | 0/13 [00:00<?, ?ba/s]
 #2:   0%|          | 0/13 [00:00<?, ?ba/s]
 #3:   0%|          | 0/13 [00:00<?, ?ba/s]
 #4:   0%|          | 0/13 [00:00<?, ?ba/s]
 #5:   0%|          | 0/13 [00:00<?, ?ba/s]
 #0:   8%|          | 1/13 [00:00<?, ?ba/s]
 #1:   8%|          | 1/13 [00:00<?, ?ba/s]
...
```

Instead, it would be welcome if we had the option to only show the progress of rank 0.
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3177/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}