code: def load_module_asdict(
      filename: Union[str, os.PathLike] = None,
      update: bool = False,
      **kwds,
  ) -> dict:
      """
      Load the contents of a saved module into a dictionary.
  
      ``load_module_asdict()`` is the near-equivalent of::
  
          lambda filename: vars(dill.load_module(filename)).copy()
  
      however, does not alter the original module. Also, the path of
      the loaded module is stored in the ``__session__`` attribute.
  
      Args:
          filename: a path-like object or a readable stream. If `None`
              (the default), read from a named file in a temporary directory.
          update: if `True`, initialize the dictionary with the current state
              of the module prior to loading the state stored at filename.
          **kwds: extra keyword arguments passed to :py:class:`Unpickler()`
  
      Raises:
          :py:exc:`UnpicklingError`: if unpickling fails
  
      Returns:
          A copy of the restored module's dictionary.
  
      Note:
          If ``update`` is True, the corresponding module may first be imported
          into the current namespace before the saved state is loaded from
          filename to the dictionary. Note that any module that is imported into
          the current namespace as a side-effect of using ``update`` will not be
          modified by loading the saved module in filename to a dictionary.
  
      Example:
          >>> import dill
          >>> alist = [1, 2, 3]
          >>> anum = 42
          >>> dill.dump_module()
          >>> anum = 0
          >>> new_var = 'spam'
          >>> main = dill.load_module_asdict()
          >>> main['__name__'], main['__session__']
          ('__main__', '/tmp/session.pkl')
          >>> main is globals() # loaded objects don't reference globals
          False
          >>> main['alist'] == alist
          True
          >>> main['alist'] is alist # was saved by value
          False
          >>> main['anum'] == anum # changed after the session was saved
          False
          >>> new_var in main # would be True if the option 'update' was set
          False
      """
      if "module" in kwds:
          raise TypeError(
              "'module' is an invalid keyword argument for load_module_asdict()"
          )
      if hasattr(filename, "read"):
          file = filename
      else:
          if filename is None:
              filename = str(TEMPDIR / "session.pkl")
          file = open(filename, "rb")
      try:
          file = _make_peekable(file)
          main_name = _identify_module(file)
          old_main = sys.modules.get(main_name)
          main = ModuleType(main_name)
          if update:
              if old_main is None:
                  old_main = _import_module(main_name)
              main.__dict__.update(old_main.__dict__)
          else:
              main.__builtins__ = __builtin__
          sys.modules[main_name] = main
          load_module(file, **kwds)
      finally:
          if not hasattr(filename, "read"):  # if newly opened file
              file.close()
          try:
              if old_main is None:
                  del sys.modules[main_name]
              else:
                  sys.modules[main_name] = old_main
          except NameError:  # failed before setting old_main
              pass
      main.__session__ = str(filename)
      return main.__dict__
  
imports: import re
  import os
  import sys
  import warnings
  from dill import _dill, Pickler, Unpickler
  from ._dill import BuiltinMethodType, FunctionType, MethodType, ModuleType, TypeType, _import_module, _is_builtin_module, _is_imported_module, _main_module, _reverse_typemap, __builtin__
  from typing import Optional, Union
  import pathlib
  import tempfile
label_desc: Use image node_id 11 for calling a global function with example usage: load_module_asdict(filename, update) and returns: main