code: def change_env(name, val):
      """
      Args:
          name(str): name of the env var
          val(str or None): the value, or set to None to clear the env var.
  
      Returns:
          a context where the environment variable ``name`` being set to
          ``val``. It will be set back after the context exits.
      """
      oldval = os.environ.get(name, None)
  
      if val is None:
          try:
              del os.environ[name]
          except KeyError:
              pass
      else:
          os.environ[name] = val
  
      yield
  
      if oldval is None:
          try:
              del os.environ[name]
          except KeyError:
              pass
      else:
          os.environ[name] = oldval
  
file_path: tensorpack/tensorpack/utils/utils.py
imports: import inspect
  import numpy
  import re
  import os
  import sys
  from contextlib import contextmanager
  from datetime import datetime, timedelta
  from tqdm import tqdm
  from .None import logger
  from .concurrency import subproc_call
label_desc: Use image node_id 2 for calling a global function with example usage: change_env(name, val) without return types