code: def clear_environment():
      """
      A context manager that will cache origin `os.environ` and replace it with a empty dictionary in this context.
  
      When this context exits, the cached `os.environ` will be back.
  
      Example:
  
      ```python
      >>> import os
      >>> from accelerate.utils import clear_environment
  
      >>> os.environ["FOO"] = "bar"
      >>> with clear_environment():
      ...     print(os.environ)
      ...     os.environ["FOO"] = "new_bar"
      ...     print(os.environ["FOO"])
      {}
      new_bar
  
      >>> print(os.environ["FOO"])
      bar
      ```
      """
      _old_os_environ = os.environ
      os.environ = dict()
  
      yield
  
      os.environ = _old_os_environ
  
imports: import collections
  import os
  import platform
  import re
  import socket
  from contextlib import contextmanager
  from functools import partial
  from types import MethodType
  from typing import OrderedDict
  import torch
  from packaging.version import Version
  from safetensors.torch import save_file
  from ..commands.config.default import write_basic_config
  from ..logging import get_logger
  from ..state import PartialState
  from .constants import FSDP_PYTORCH_VERSION
  from .dataclasses import DistributedType
  from .imports import is_deepspeed_available, is_torch_distributed_available, is_tpu_available
  from .modeling import id_tensor_storage
  from .transformer_engine import convert_model
  from .versions import is_torch_version
label_desc: Use image node_id 6 for calling a global function with example usage: clear_environment() without return types