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
  
file_path: catboost/contrib/tools/python3/src/Lib/importlib/resources/_common.py
imports: import os
  import pathlib
  import tempfile
  import functools
  import contextlib
  import types
  import importlib
  from typing import Union, Optional
  from .abc import ResourceReader, Traversable
  from ._adapters import wrap_spec
label_desc: Use image node_id 6 for calling a global function with example usage: _tempfile(reader, suffix) without return types