Should be able to turn off logging
# 🚀 Feature request

When doing a simple pipeline, I want to supress:
```
Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 230/230 [00:00<00:00, 136kB/s]
convert squad examples to features: 100%|█████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 241.08it/s]
add example index and unique id: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 7037.42it/s]
```
## Motivation

<!-- Please outline the motivation for the proposal. Is your feature request
     related to a problem? e.g., I'm always frustrated when [...]. If this is related
     to another GitHub issue, please link here too. -->

## Your contribution

My code is pretty straightforward:
```
    args = parse_args()
    f = open(args.text_path, "r")
    context = f.read()
    # print(context)

    tokenizer = AutoTokenizer.from_pretrained(args.model)
    model = AutoModelForQuestionAnswering.from_pretrained(args.model)

    qa = pipeline('question-answering',
                  model='distilbert-base-uncased-distilled-squad', tokenizer='bert-base-cased')
    response = qa(context=context,
                  question=args.question)

    print(response['answer'])
```
Any progress on this? Has anyone found a way to disable the logging this?


The issue appears to be tqdm. A work-around is to disable it before importing transformers:
```
import tqdm

def nop(it, *a, **k):
    return it
tqdm.tqdm = nop
import transformers
```<|||||>I agree that it's a valid requirement, we'll look into it<|||||>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.
<|||||>Wish this would stay open.<|||||>Logger could be really annoying when it comes to applications. Should have some way to turn it off.<|||||>Here you go:

```
# To control logging level for various modules used in the application:
import logging
import re
def set_global_logging_level(level=logging.ERROR, prefices=[""]):
    """
    Override logging levels of different modules based on their name as a prefix.
    It needs to be invoked after the modules have been loaded so that their loggers have been initialized.

    Args:
        - level: desired level. e.g. logging.INFO. Optional. Default is logging.ERROR
        - prefices: list of one or more str prefices to match (e.g. ["transformers", "torch"]). Optional.
          Default is `[""]` to match all active loggers.
          The match is a case-sensitive `module_name.startswith(prefix)`
    """
    prefix_re = re.compile(fr'^(?:{ "|".join(prefices) })')
    for name in logging.root.manager.loggerDict:
        if re.match(prefix_re, name):
            logging.getLogger(name).setLevel(level)
```
Usage:

1. override all module-specific loggers to a desired level (except whatever got logged during modules importing)
```
import everything, you, need
import logging
set_global_logging_level(logging.ERROR)
```

2. In case of transformers you most likely need to call it as:
```
import transformers, torch, ...
import logging
set_global_logging_level(logging.ERROR, ["transformers", "nlp", "torch", "tensorflow", "tensorboard", "wandb"])
```
add/remove modules as needed.


To disable logging globally - place at the beginning of the script
```
import logging
logging.disable(logging.INFO) # disable INFO and DEBUG logging everywhere
# or 
# logging.disable(logging.WARNING) # disable WARNING, INFO and DEBUG logging everywhere
```

If desired, `set_global_logging_level` could be expanded to be a scope manager too.<|||||>Will that kill tqdm? I want to keep tqdm!<|||||>> Will that kill tqdm? I want to keep tqdm!

```
set_global_logging_level(logging.ERROR, ["transformers", "nlp", "torch", "tensorflow", "tensorboard", "wandb"])

from tqdm import tqdm
for i in tqdm(range(10000)): x = i**i
```
works just fine

and so does disable all:
```
set_global_logging_level(logging.ERROR])

from tqdm import tqdm
for i in tqdm(range(10000)): x = i**i
```

or in the case of "total logging silence" setting:
```
import logging
logging.disable(logging.INFO) # disable INFO and DEBUG logging everywhere

from tqdm import tqdm
for i in tqdm(range(10000)): x = i**i
```

works too. 

I don't think it uses `logging`.
<|||||>PR with the proposed code, plus adding the ability to do that during `pytest` https://github.com/huggingface/transformers/pull/6816<|||||>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 was resolved by https://github.com/huggingface/transformers/pull/6434