class_docstr: A subclass of the module type which triggers loading upon attribute access.
class_docstr_tok: ["A","subclass","of","the","module","type","which","triggers","loading","upon","attribute","access","."]
docstr: Trigger the load of the module and return the attribute.
docstr_tok: ["Trigger","the","load","of","the","module","and","return","the","attribute","."]
code: def __getattribute__(self, attr):
      """Trigger the load of the module and return the attribute."""
      # All module metadata must be garnered from __spec__ in order to avoid
      # using mutated values.
      # Stop triggering this method.
      self.__class__ = types.ModuleType
      # Get the original name to make sure no object substitution occurred
      # in sys.modules.
      original_name = self.__spec__.name
      # Figure out exactly what attributes were mutated between the creation
      # of the module and now.
      attrs_then = self.__spec__.loader_state["__dict__"]
      attrs_now = self.__dict__
      attrs_updated = {}
      for key, value in attrs_now.items():
          # Code that set the attribute may have kept a reference to the
          # assigned object, making identity more important than equality.
          if key not in attrs_then:
              attrs_updated[key] = value
          elif id(attrs_now[key]) != id(attrs_then[key]):
              attrs_updated[key] = value
      self.__spec__.loader.exec_module(self)
      # If exec_module() was used directly there is no guarantee the module
      # object was put into sys.modules.
      if original_name in sys.modules:
          if id(self) != id(sys.modules[original_name]):
              raise ValueError(
                  f"module object for {original_name!r} "
                  "substituted in sys.modules during a lazy "
                  "load"
              )
      # Update after loading since that's what would happen in an eager
      # loading situation.
      self.__dict__.update(attrs_updated)
      return getattr(self, attr)
  
imports: from ._abc import Loader
  from ._bootstrap import module_from_spec
  from ._bootstrap import _resolve_name
  from ._bootstrap import spec_from_loader
  from ._bootstrap import _find_spec
  from ._bootstrap_external import MAGIC_NUMBER
  from ._bootstrap_external import _RAW_MAGIC_NUMBER
  from ._bootstrap_external import cache_from_source
  from ._bootstrap_external import decode_source
  from ._bootstrap_external import source_from_cache
  from ._bootstrap_external import spec_from_file_location
  from contextlib import contextmanager
  import _imp
  import functools
  import sys
  import types
  import warnings
label_desc: Use image node_id 1 for calling the _LazyModule obj's underlying member method code with example usage: obj.__getattribute__(attr) and returns: getattr