Consolidate mypy tests and args (#50631)
Summary:
This PR helps with https://github.com/pytorch/pytorch/issues/50513 by reducing the complexity of our `mypy` test suite and making it easier to reproduce on the command line. Previously, to reproduce how `mypy` was actually run on tracked source files (ignoring the doctest typechecking) in CI, you technically needed to run 9 different commands with various arguments:
```
$ mypy --cache-dir=.mypy_cache/normal --check-untyped-defs --follow-imports silent
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/module_list.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/namedtuple.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/opt_size.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/size.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/tensor_copy.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/torch_cuda_random.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/torch_optim.py
$ mypy --cache-dir=.mypy_cache/strict --config mypy-strict.ini
```
Now you only have to run 2 much simpler commands:
```
$ mypy
$ mypy --config mypy-strict.ini
```
One reason this is useful is because it will make it easier to integrate PyTorch's `mypy` setup into editors (remaining work on this to be done in a followup PR).
Also, as shown in the test plan, this also reduces the time it takes to run `test/test_type_hints.py` incrementally, by reducing the number of times `mypy` is invoked while still checking the same set of files with the same configs.
(Because this PR merges `test_type_hint_examples` (added in https://github.com/pytorch/pytorch/issues/34595) into `test_run_mypy` (added in https://github.com/pytorch/pytorch/issues/36584), I've added some people involved in those PRs as reviewers, in case there's a specific reason they weren't combined in the first place.)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50631
Test Plan:
Run this twice (the first time is to warm the cache):
```
$ python test/test_type_hints.py -v
```
- *Before:*
```
test_doc_examples (__main__.TestTypeHints)
Run documentation examples through mypy. ... ok
test_run_mypy (__main__.TestTypeHints)
Runs mypy over all files specified in mypy.ini ... ok
test_run_mypy_strict (__main__.TestTypeHints)
Runs mypy over all files specified in mypy-strict.ini ... ok
test_type_hint_examples (__main__.TestTypeHints)
Runs mypy over all the test examples present in ... ok
----------------------------------------------------------------------
Ran 4 tests in 5.090s
OK
```
You can also just run `mypy` to see how many files it checks:
```
$ mypy --cache-dir=.mypy_cache/normal --check-untyped-defs --follow-imports silent
Success: no issues found in 1192 source files
```
- *After:*
```
test_doc_examples (__main__.TestTypeHints)
Run documentation examples through mypy. ... ok
test_run_mypy (__main__.TestTypeHints)
Runs mypy over all files specified in mypy.ini ... ok
test_run_mypy_strict (__main__.TestTypeHints)
Runs mypy over all files specified in mypy-strict.ini ... ok
----------------------------------------------------------------------
Ran 3 tests in 2.404s
OK
```
Now `mypy` checks 7 more files, which is the number in `test/type_hint_tests`:
```
$ mypy
Success: no issues found in 1199 source files
```
Reviewed By: zou3519
Differential Revision: D25932660
Pulled By: samestep
fbshipit-source-id: 26c6f00f338e7b44954e5ed89522ce24e2fdc5f0