code: def for_file(
      cls: type[ModuleAnalyzer], filename: str, modname: str
  ) -> ModuleAnalyzer:
      if ("file", filename) in cls.cache:
          return cls.cache["file", filename]
      try:
          with tokenize.open(filename) as f:
              string = f.read()
          obj = cls(string, modname, filename)
          cls.cache["file", filename] = obj
      except Exception as err:
          raise PycodeError("error opening %r" % filename, err) from err
      return obj
  
file_path: sphinx/sphinx/pycode/__init__.py
imports: from __future__ import annotations
  import tokenize
  from importlib import import_module
  from os import path
  from typing import TYPE_CHECKING, Any
  from sphinx.errors import PycodeError
  from sphinx.pycode.parser import Parser
label_desc: Use image node_id 3 for calling the ModuleAnalyzer obj's underlying member method code with example usage: obj.for_file(cls, filename, modname) and returns: obj, cls