Use separate mypy caches for TestTypeHints cases (#50539)
Summary:
Addresses one of the speed points in https://github.com/pytorch/pytorch/issues/50513 by making the `TestTypeHints` suite much faster when run incrementally. Also fixes an issue (at least on 5834438090a1b3206347e30968e48f44251a53a1) where running that suite repeatedly results in a failure every other run (see the test plan below).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50539
Test Plan:
First clear your [`mypy` cache](https://mypy.readthedocs.io/en/stable/command_line.html#incremental-mode):
```
$ rm -r .mypy_cache
```
Then run this twice:
```
$ python test/test_type_hints.py
```
- *Before:*
```
....
----------------------------------------------------------------------
Ran 4 tests in 212.340s
OK
```
```
.F..
======================================================================
FAIL: test_run_mypy (__main__.TestTypeHints)
Runs mypy over all files specified in mypy.ini
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_type_hints.py", line 214, in test_run_mypy
self.fail(f"mypy failed: {stdout} {stderr}")
AssertionError: mypy failed: torch/quantization/fx/quantize.py:138: error: "Tensor" not callable [operator]
Found 1 error in 1 file (checked 1189 source files)
----------------------------------------------------------------------
Ran 4 tests in 199.331s
FAILED (failures=1)
```
- *After:*
```
....
----------------------------------------------------------------------
Ran 4 tests in 212.815s
OK
```
```
....
----------------------------------------------------------------------
Ran 4 tests in 5.491s
OK
```
Reviewed By: xuzhao9
Differential Revision: D25912363
Pulled By: samestep
fbshipit-source-id: dac38c890399193699c57b6c9fa8df06a88aee5d