class_docstr: Represents an environment to import modules from.
  
  By default, you can figure out what module an object belongs by checking
  __module__ and importing the result using __import__ or importlib.import_module.
  
  torch.package introduces module importers other than the default one.
  Each PackageImporter introduces a new namespace. Potentially a single
  name (e.g. 'foo.bar') is present in multiple namespaces.
  
  It supports two main operations:
      import_module: module_name -> module object
      get_name: object -> (parent module name, name of obj within module)
  
  The guarantee is that following round-trip will succeed or throw an ObjNotFoundError/ObjMisMatchError.
      module_name, obj_name = env.get_name(obj)
      module = env.import_module(module_name)
      obj2 = getattr(module, obj_name)
      assert obj1 is obj2
docstr: Find the module name an object belongs to.
  
  This should be considered internal for end-users, but developers of
  an importer can override it to customize the behavior.
  
  Taken from pickle.py, but modified to exclude the search into sys.modules
docstr_tok: ["Find","the","module","name","an","object","belongs","to",".","This","should","be","considered","internal","for","end-users",",","but","developers","of","an","importer","can","override","it","to","customize","the","behavior",".","Taken","from","pickle.py",",","but","modified","to","exclude","the","search","into","sys.modules"]
code: def whichmodule(self, obj: Any, name: str) -> str:
      """Find the module name an object belongs to.
  
      This should be considered internal for end-users, but developers of
      an importer can override it to customize the behavior.
  
      Taken from pickle.py, but modified to exclude the search into sys.modules
      """
      module_name = getattr(obj, "__module__", None)
      if module_name is not None:
          return module_name
  
      # Protect the iteration by using a list copy of self.modules against dynamic
      # modules that trigger imports of other modules upon calls to getattr.
      for module_name, module in self.modules.copy().items():
          if (
              module_name == "__main__"
              or module_name == "__mp_main__"  # bpo-42406
              or module is None
          ):
              continue
          try:
              if _getattribute(module, name)[0] is obj:
                  return module_name
          except AttributeError:
              pass
  
      return "__main__"
  
imports: import importlib
  from abc import ABC, abstractmethod
  from pickle import _getattribute, _Pickler, whichmodule
  from types import ModuleType
  from typing import Any, Dict, List, Optional, Tuple
  from ._mangling import demangle, get_mangle_prefix, is_mangled
label_desc: Use image node_id 3 for calling the Importer obj's underlying member method code with example usage: obj.whichmodule(obj, name) and returns: str, module_name, module_name