code: def change_cwd(path, quiet=False):
      """Return a context manager that changes the current working directory.
  
      Arguments:
  
        path: the directory to use as the temporary current working directory.
  
        quiet: if False (the default), the context manager raises an exception
          on error.  Otherwise, it issues only a warning and keeps the current
          working directory the same.
  
      """
      saved_dir = os.getcwd()
      try:
          os.chdir(os.path.realpath(path))
      except OSError as exc:
          if not quiet:
              raise
          warnings.warn(
              f"tests may fail, unable to change the current working "
              f"directory to {path!r}: {exc}",
              RuntimeWarning,
              stacklevel=3,
          )
      try:
          yield os.getcwd()
      finally:
          os.chdir(saved_dir)
  
imports: import collections.abc
  import contextlib
  import errno
  import os
  import re
  import stat
  import string
  import sys
  import time
  import unittest
  import warnings
  from test import support
label_desc: Use image node_id 15 for calling a global function with example usage: change_cwd(path, quiet) without return types