code: def run_mypy(tests: list[Path]) -> dict[Pos, MypyError]:
      result = mypy.api.run([str(t) for t in tests])
      mypy_fails: dict[Pos, MypyError] = {}
      for line in result[0].strip().split("\n"):
          if re.match(
              r"^Found (\d)+ error(s?) in (\d)+ file(s?) "
              r"\(checked (\d)+ source file(s?)\)$",
              line,
          ):
              continue
          m = re.match(r"^(.+):(\d+): (error|note): (.+)$", line)
          assert m is not None, line
          pos = Pos(m.group(1), int(m.group(2)))
          text = m.group(4)
          if pos in mypy_fails:
              mypy_fails[pos].mes = mypy_fails[pos].mes + "\n" + text
          else:
              m = re.match(r"^(.+)\[(.+)\]$", text)
              assert m is not None
              mypy_fails[pos] = MypyError(m.group(2), m.group(1))
      return mypy_fails
  
file_path: cupy/tests/typing_tests/test_typing.py
imports: import dataclasses
  from pathlib import Path
  import shutil
  import tempfile
  import typing
  import re
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: run_mypy(tests) and returns: mypy_fails