code: def env_var(key: str, value: Optional[str]) -> Iterator[None]:
      """Sets/clears an environment variable within a Python context."""
      # Get the previous value and then override it.
      previous_value = os.environ.get(key)
      set_env_var(key, value)
      try:
          yield
      finally:
          # Restore to previous value.
          set_env_var(key, previous_value)
  
file_path: pytorch/tools/test/test_cmake.py
imports: import contextlib
  import os
  import typing
  import unittest
  import unittest.mock
  from typing import Iterator, Optional, Sequence
  import tools.setup_helpers.cmake
  import tools.setup_helpers.env
label_desc: Use image node_id 1 for calling a global function with example usage: env_var(key, value) without return types