code: def _tempfile(
      reader,
      suffix="",
      # gh-93353: Keep a reference to call os.remove() in late Python
      # finalization.
      *,
      _os_remove=os.remove,
  ):
      # Not using tempfile.NamedTemporaryFile as it leads to deeper 'try'
      # blocks due to the need to close the temporary file to work on Windows
      # properly.
      fd, raw_path = tempfile.mkstemp(suffix=suffix)
      try:
          try:
              os.write(fd, reader())
          finally:
              os.close(fd)
          del reader
          yield pathlib.Path(raw_path)
      finally:
          try:
              _os_remove(raw_path)
          except FileNotFoundError:
              pass
  
imports: import os
  import pathlib
  import tempfile
  import functools
  import contextlib
  import types
  import importlib
  import inspect
  import warnings
  import itertools
  from typing import Union, Optional, cast
  from .abc import ResourceReader, Traversable
  from ._compat import wrap_spec
label_desc: Use image node_id 9 for calling a global function with example usage: _tempfile(reader, suffix) without return types