code: def _pdf_to_hocr(  # noqa: D417
      input_pdf: Path,
      output_folder: Path,
      *,
      language: Iterable[str] | None = None,
      image_dpi: int | None = None,
      jobs: int | None = None,
      use_threads: bool | None = None,
      title: str | None = None,
      author: str | None = None,
      subject: str | None = None,
      keywords: str | None = None,
      rotate_pages: bool | None = None,
      remove_background: bool | None = None,
      deskew: bool | None = None,
      clean: bool | None = None,
      clean_final: bool | None = None,
      unpaper_args: str | None = None,
      oversample: int | None = None,
      remove_vectors: bool | None = None,
      force_ocr: bool | None = None,
      skip_text: bool | None = None,
      redo_ocr: bool | None = None,
      skip_big: float | None = None,
      pages: str | None = None,
      max_image_mpixels: float | None = None,
      tesseract_config: Iterable[str] | None = None,
      tesseract_pagesegmode: int | None = None,
      tesseract_oem: int | None = None,
      tesseract_thresholding: int | None = None,
      tesseract_timeout: float | None = None,
      tesseract_non_ocr_timeout: float | None = None,
      tesseract_downsample_above: int | None = None,
      tesseract_downsample_large_images: bool | None = None,
      rotate_pages_threshold: float | None = None,
      user_words: os.PathLike | None = None,
      user_patterns: os.PathLike | None = None,
      continue_on_soft_render_error: bool | None = None,
      invalidate_digital_signatures: bool | None = None,
      plugin_manager=None,
      plugins: Sequence[StrPath] | None = None,
      keep_temporary_files: bool | None = None,
      **kwargs,
  ):
      """Partially run OCRmyPDF and produces an output folder containing hOCR files.
  
      Given a PDF file, this function will run OCRmyPDF up to the point where
      the PDF is rasterized to images, OCRed, and the hOCR files are produced,
      all of which are saved to the output folder. This is useful for applications
      that want to provide an interface for users to edit the text before
      rendering the final PDF.
  
      Use :func:`hocr_to_ocr_pdf` to produce the final PDF.
  
      For arguments not explicitly documented here, see documentation for the
      equivalent command line parameter.
  
      This API is **experimental** and subject to change.
  
      Args:
          input_pdf: Input PDF file path.
          output_folder: Output folder path.
          **kwargs: Keyword arguments.
      """
      # No new variable names should be assigned until these two steps are run
      create_options_kwargs = {
          k: v
          for k, v in locals().items()
          if k not in {"input_pdf", "output_folder", "kwargs"}
      }
      create_options_kwargs.update(kwargs)
  
      parser = get_parser()
  
      with _api_lock:
          if not plugin_manager:
              plugin_manager = get_plugin_manager(plugins)
          plugin_manager.hook.add_options(
              parser=parser
          )  # pylint: disable=no-member
  
          cmdline, deferred = _kwargs_to_cmdline(
              defer_kwargs={"input_pdf", "output_folder", "plugins"},
              **create_options_kwargs,
          )
          cmdline.append(str(input_pdf))
          cmdline.append(str(output_folder))
          parser.enable_api_mode()
          options = parser.parse_args(cmdline)
          for keyword, val in deferred.items():
              setattr(options, keyword, val)
          delattr(options, "output_file")
          setattr(options, "output_folder", output_folder)
  
          return run_hocr_pipeline(
              options=options, plugin_manager=plugin_manager
          )
  
imports: from __future__ import annotations
  import logging
  import os
  import sys
  import threading
  from argparse import Namespace
  from collections.abc import Iterable, Sequence
  from enum import IntEnum
  from io import IOBase
  from pathlib import Path
  from typing import AnyStr, BinaryIO, Union
  from warnings import warn
  import pluggy
  from ocrmypdf._logging import PageNumberFilter
  from ocrmypdf._pipelines.hocr_to_ocr_pdf import run_hocr_to_ocr_pdf_pipeline
  from ocrmypdf._pipelines.ocr import run_pipeline, run_pipeline_cli
  from ocrmypdf._pipelines.pdf_to_hocr import run_hocr_pipeline
  from ocrmypdf._plugin_manager import get_plugin_manager
  from ocrmypdf._validation import check_options
  from ocrmypdf.cli import ArgumentParser, get_parser
  from ocrmypdf.helpers import is_iterable_notstr
label_desc: Use image node_id 5 for calling a global function with example usage: _pdf_to_hocr(input_pdf, output_folder) and returns: run_hocr_pipeline