code: def temp_dir(remover=shutil.rmtree):
      """
      Create a temporary directory context. Pass a custom remover
      to override the removal behavior.
  
      >>> import pathlib
      >>> with temp_dir() as the_dir:
      ...     assert os.path.isdir(the_dir)
      ...     _ = pathlib.Path(the_dir).joinpath('somefile').write_text('contents')
      >>> assert not os.path.exists(the_dir)
      """
      temp_dir = tempfile.mkdtemp()
      try:
          yield temp_dir
      finally:
          remover(temp_dir)
  
imports: import os
  import subprocess
  import contextlib
  import functools
  import tempfile
  import shutil
  import operator
  import warnings
label_desc: Use image node_id 4 for calling a global function with example usage: temp_dir(remover) without return types