code: def collect_xfails(tests: list[Path]) -> dict[Pos, MypyError]:
      xfails: dict[Pos, MypyError] = {}
      for t in tests:
          with open(t) as f:
              for i, text in enumerate(f.readlines()):
                  pos = Pos(str(t), i + 1)
                  if "# E:" in text:
                      m = re.match(
                          r".*# E:(?P<mes>.*)\[(?P<type>.+)\]", text
                      )
                      assert (
                          m is not None
                      ), f"{text} (Hint: Missing Error code?)"
                      xfails[pos] = MypyError(
                          m.group(2), m.group(1).strip()
                      )
      return xfails
  
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 2 for calling a global function with example usage: collect_xfails(tests) and returns: xfails