code: def temp_dir(path=None, quiet=False):
      """Return a context manager that creates a temporary directory.
  
      Arguments:
  
        path: the directory to create temporarily.  If omitted or None,
          defaults to creating a temporary directory using tempfile.mkdtemp.
  
        quiet: if False (the default), the context manager raises an exception
          on error.  Otherwise, if the path is specified and cannot be
          created, only a warning is issued.
  
      """
      import tempfile
  
      dir_created = False
      if path is None:
          path = tempfile.mkdtemp()
          dir_created = True
          path = os.path.realpath(path)
      else:
          try:
              os.mkdir(path)
              dir_created = True
          except OSError as exc:
              if not quiet:
                  raise
              warnings.warn(
                  f"tests may fail, unable to create "
                  f"temporary directory {path!r}: {exc}",
                  RuntimeWarning,
                  stacklevel=3,
              )
      if dir_created:
          pid = os.getpid()
      try:
          yield path
      finally:
          # In case the process forks, let only the parent remove the
          # directory. The child has a different process id. (bpo-30028)
          if dir_created and pid == os.getpid():
              rmtree(path)
  
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 14 for calling a global function with example usage: temp_dir(path, quiet) without return types