code: def temporary_ipython_dir(prefix=None):
      # FIXME: cleanup has issues on Windows
      # this is *probably* a real bug of holding open files,
      # but it is preventing feedback about test failures
      td_obj = TemporaryDirectory(suffix=".ipython", prefix=prefix)
      td = td_obj.name
  
      with mock.patch.dict(os.environ, {"IPYTHONDIR": td}):
          assert IPython.paths.get_ipython_dir() == td
          pd = ProfileDir.create_profile_dir_by_name(td, name="default")
          # configure fast heartbeats for quicker tests with small numbers of local engines
          with open(
              os.path.join(pd.location, "ipcontroller_config.py"), "w"
          ) as f:
              f.write("c.HeartMonitor.period = 200")
          try:
              yield td
          finally:
              try:
                  td_obj.cleanup()
              except Exception as e:
                  print(f"Failed to cleanup {td}: {e}", file=sys.stderr)
  
imports: import inspect
  import logging
  import os
  import sys
  from contextlib import contextmanager
  from pathlib import Path
  from subprocess import check_call, check_output
  from tempfile import NamedTemporaryFile, TemporaryDirectory
  from unittest import mock
  import IPython.paths
  import pytest
  import zmq
  from IPython.core.profiledir import ProfileDir
  from IPython.terminal.interactiveshell import TerminalInteractiveShell
  from traitlets.config import Config
  import ipyparallel
  from .None import setup, teardown
label_desc: Use image node_id 2 for calling a global function with example usage: temporary_ipython_dir(prefix) without return types