code: def import_state(**kwargs):
      """Context manager to manage the various importers and stored state in the
      sys module.
  
      The 'modules' attribute is not supported as the interpreter state stores a
      pointer to the dict that the interpreter uses internally;
      reassigning to sys.modules does not have the desired effect.
  
      """
      originals = {}
      try:
          for attr, default in (
              ("meta_path", []),
              ("path", []),
              ("path_hooks", []),
              ("path_importer_cache", {}),
          ):
              originals[attr] = getattr(sys, attr)
              if attr in kwargs:
                  new_value = kwargs[attr]
                  del kwargs[attr]
              else:
                  new_value = default
              setattr(sys, attr, new_value)
          if len(kwargs):
              raise ValueError(
                  "unrecognized arguments: {}".format(kwargs)
              )
          yield
      finally:
          for attr, value in originals.items():
              setattr(sys, attr, value)
  
imports: import builtins
  import contextlib
  import errno
  import functools
  from importlib import machinery, util, invalidate_caches
  import marshal
  import os
  import os.path
  from test.support import import_helper
  from test.support import os_helper
  import unittest
  import sys
  import tempfile
  import types
label_desc: Use image node_id 11 for calling a global function with example usage: import_state() without return types