code: def _run_mypy() -> Dict[str, List[str]]:
      """Clears the cache and run mypy before running any of the typing tests."""
      if os.path.isdir(CACHE_DIR):
          shutil.rmtree(CACHE_DIR)
  
      rc: Dict[str, List[str]] = {}
      for directory in (REVEAL_DIR, PASS_DIR, FAIL_DIR):
          # Run mypy
          stdout, stderr, _ = api.run(
              [
                  "--show-absolute-path",
                  "--config-file",
                  MYPY_INI,
                  "--cache-dir",
                  CACHE_DIR,
                  directory,
              ]
          )
          assert not stderr, directory
          stdout = stdout.replace("*", "")
  
          # Parse the output
          iterator = itertools.groupby(
              stdout.split("\n"), key=_key_func
          )
          rc.update((k, list(v)) for k, v in iterator if k)
      return rc
  
imports: import itertools
  import os
  import re
  import shutil
  import unittest
  from collections import defaultdict
  from threading import Lock
  from typing import Dict, IO, List, Optional
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, TestCase
label_desc: Use image node_id 3 for calling a global function with example usage: _run_mypy() and returns: rc