code: def temporary_env(newenv):
      """Completely replace the environment variables with the specified dict.
  
      Use as a context manager::
  
          with temporary_env({'PATH': my_path}):
              ...
      """
      orig_env = os.environ.copy()
      os.environ.clear()
      os.environ.update(newenv)
      try:
          yield
      finally:
          os.environ.clear()
          os.environ.update(orig_env)
  
imports: import contextlib
  import os
label_desc: Use image node_id 1 for calling a global function with example usage: temporary_env(newenv) without return types