code: def _image_to_ocr_text(
      page_context: PageContext, ocr_image_out: Path
  ) -> tuple[Path, Path]:
      """Run OCR engine on image to create OCR PDF and text file."""
      options = page_context.options
      if options.pdf_renderer.startswith("hocr"):
          hocr_out, text_out = ocr_engine_hocr(
              ocr_image_out, page_context
          )
          ocr_out = render_hocr_page(hocr_out, page_context)
      elif options.pdf_renderer == "sandwich":
          ocr_out, text_out = ocr_engine_textonly_pdf(
              ocr_image_out, page_context
          )
      else:
          raise NotImplementedError(
              f"pdf_renderer {options.pdf_renderer}"
          )
      return ocr_out, text_out
  
imports: from __future__ import annotations
  import argparse
  import logging
  import logging.handlers
  from collections.abc import Sequence
  from functools import partial
  from pathlib import Path
  from tempfile import mkdtemp
  import PIL
  from ocrmypdf._concurrent import Executor
  from ocrmypdf._graft import OcrGrafter
  from ocrmypdf._jobcontext import PageContext, PdfContext
  from ocrmypdf._pipeline import copy_final, get_pdfinfo, is_ocr_required, merge_sidecars, ocr_engine_hocr, ocr_engine_textonly_pdf, render_hocr_page, triage, validate_pdfinfo_options
  from ocrmypdf._pipelines._common import PageResult, cli_exception_handler, manage_debug_log_handler, manage_work_folder, postprocess, process_page, report_output_pdf, set_thread_pageno, setup_pipeline, worker_init
  from ocrmypdf._plugin_manager import OcrmypdfPluginManager
  from ocrmypdf._progressbar import ProgressBar
  from ocrmypdf._validation import check_requested_output_file, create_input_file
  from ocrmypdf.exceptions import ExitCode
label_desc: Use image node_id 1 for calling a global function with example usage: _image_to_ocr_text(page_context, ocr_image_out) and returns: ocr_out,  text_out