[examples `run_glue.py`] missing requirements `scipy`, `sklearn`
Author: stas00
Pull request: yes

`run_glue.py` requires `sklearn` (which installs `scipy`)

When running:
```
RUN_SLOW=1 pytest tests/deepspeed/test_model_zoo.py::TestDeepSpeedModelZoo::test_zero_to_fp32_zero2_clas_xlnet -sv
```
which internally calls `examples/pytorch/text-classification/run_glue.py`

After 
```
pip install .[testing]
pip install deepspeed
pip install -r  examples/pytorch/text-classification/requirements.txt
```
it fails:
```
metric = load_metric("glue", data_args.task_name)
[...]

ImportError:File "/tmp/actions-runner/gh-runner/lib/python3.6/site-packages/datasets/load.py", line 819, in load_metric
781
E               metric = load_metric("glue", data_args.task_name)
[...]
 To be able to use this metric, you need to install the following dependencies['scipy', 'sklearn'] using 'pip install scipy sklearn' for instance'
```

it looks like it's enough to require `sklearn` - `scipy` gets installed along.
```
pip install sklearn
Collecting sklearn
  Downloading sklearn-0.0.tar.gz (1.1 kB)
Collecting scikit-learn
  Downloading scikit_learn-1.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (25.8 MB)
     |████████████████████████████████| 25.8 MB 814 kB/s 
Requirement already satisfied: joblib>=0.11 in /mnt/nvme1/anaconda3/envs/ds-test/lib/python3.8/site-packages (from scikit-learn->sklearn) (1.0.1)
Collecting scipy>=1.1.0
  Using cached scipy-1.7.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (28.4 MB)
Collecting threadpoolctl>=2.0.0
  Using cached threadpoolctl-2.2.0-py3-none-any.whl (12 kB)
Requirement already satisfied: numpy>=1.14.6 in /mnt/nvme1/anaconda3/envs/ds-test/lib/python3.8/site-packages (from scikit-learn->sklearn) (1.21.2)
Building wheels for collected packages: sklearn
  Building wheel for sklearn (setup.py) ... done
  Created wheel for sklearn: filename=sklearn-0.0-py2.py3-none-any.whl size=1309 sha256=e55ca522573bec0880cf084944cb1e3235d38bf66ea96f54b94fc1088a6e9dde
  Stored in directory: /home/stas/.cache/pip/wheels/22/0b/40/fd3f795caaa1fb4c6cb738bc1f56100be1e57da95849bfc897
Successfully built sklearn
Installing collected packages: threadpoolctl, scipy, scikit-learn, sklearn
Successfully installed scikit-learn-1.0 scipy-1.7.1 sklearn-0.0 threadpoolctl-2.2.0
```
but may be it's best to list both explicitly.

Alternatively we should move `sklearn` from `[dev]` to `[testing]` in `setup.py`

context: Deepspeed integrating our deepspeed tests into their test suite:
https://github.com/microsoft/DeepSpeed/blob/e2de528632e122d7f359d9f5dedf4c0150cae072/.github/workflows/main.yml#L70-L98
I think it'd be too much to ask them to install `.[dev]` as it's too much unnecessary overhead.

The reason I'm considering changing this in `setup.py`'s `testing` is because any other example wanting to do metric `glue` will want those deps.

@sgugger, @LysandreJik 


Comments:
Oh, interesting! No wonder we have missing deps - it's hard to remember to maintain 3 different places I guess (`setup.py` is the 3rd place)

Note that the collected dependencies don't match the file you linked to, which means other local `requirements.txt` are out of sync:
```
$ find examples/pytorch  -name requirements.txt -exec cat {} \; | sort | uniq
accelerate
datasets >= 1.12.0
datasets >= 1.8.0
nltk
protobuf
py7zr
rouge-score
sacrebleu >= 1.4.12
sentencepiece != 0.1.92
seqeval
torch >= 1.3
torch >= 1.3.0
torch >= 1.3accelerate
torch >= 1.5
torch>=1.9.0
torchaudio
torchvision>=0.10.0accelerate
```

They had to use:
```
find examples/pytorch  -regextype posix-egrep -regex \
'.*(language-modeling|question-answering|summarization|text-classification|translation).*/requirements.txt' \
-exec pip install -r {} \;
```
Because:
```
examples/pytorch/image-classification/requirements.txt:torch>=1.9.0
```
as it forces pt version which breaks their CI env which is `torch==1.8.2`

So unfortunately I have to add a skip rule to the deepspeed test zoo with img classification models, since they use pt 1.8.2. But it'll be tested on our CI just fine.


> Note that the collected dependencies don't match the file you linked to, which means other local requirements.txt are out of sync:

I don't understand what you mean by this? For instance `rouge-score` is in the requirements file of summarization and in the test requirements file.

Let's try diff:

```
$ sort examples/pytorch/_tests_requirements.txt | uniq > together.txt
$ find examples/pytorch  -name requirements.txt -exec cat {} \; | sort | uniq > separate.txt

$ diff -u separate.txt together.txt
--- separate.txt        2021-09-28 08:56:15.281309730 -0700
+++ together.txt        2021-09-28 08:56:03.829267889 -0700
@@ -1,17 +1,22 @@
-accelerate
-datasets >= 1.12.0
-datasets >= 1.8.0
+conllu
+datasets >= 1.1.3
+elasticsearch
+faiss-cpu
+fire
+git-python==1.0.3
+jiwer
+matplotlib
 nltk
+pandas
 protobuf
-py7zr
+psutil
+pytest
 rouge-score
 sacrebleu >= 1.4.12
+scikit-learn
 sentencepiece != 0.1.92
 seqeval
-torch >= 1.3
-torch >= 1.3.0
-torch >= 1.3accelerate
-torch >= 1.5
-torch>=1.9.0
-torchaudio
-torchvision>=0.10.0accelerate
+streamlit
+tensorboard
+tensorflow_datasets
+torchvision
```

Can you see how the 2 sets of dependencies are very different from each other?

OK, so discussing this with Sylvain on slack I have now a better understanding of why the different sets of dependencies don't quite match:

1. `.[testing]` is for dependencies needed to run the test suite itself - pytest, plugins, etc.
2. `examples/pytorch/_tests_requirements.txt` is what HF Transformers CI uses to install when running the CI, which means it covers all dependencies of all example scripts which are actually tested (which means just some features)
3. Individual `examples/pytorch/*/requirements.txt` in theory should contain the exhaustive list of dependencies for all of its features.