code: def envset(
      value: Mapping[str, str] | None = None, **kw: Any
  ) -> Iterator[None]:
      """Temporarily set environment variables and undo the updates on exit.
  
      Args:
          value (optional) :
              A mapping of strings to strings to apply to os.environ
  
      Any remaining keywoard args are applied to os.environ
  
      """
      old = os.environ.copy()
      if value:
          os.environ.update(value)
      os.environ.update(**kw)
      yield
      # take care to keep the same actual dict object
      os.environ.clear()
      os.environ.update(old)
  
imports: from __future__ import annotations
  import logging
  import os
  from contextlib import contextmanager
  from typing import Any, Iterator, Mapping
label_desc: Use image node_id 1 for calling a global function with example usage: envset(value) without return types