code: def test_hocr_to_pdf_api(resources: Path, outdir: Path, outpdf: Path):
      ocrmypdf.api._pdf_to_hocr(
          resources / "ccitt.pdf",
          outdir,
          language="eng",
          skip_text=True,
          plugins=["tests/plugins/tesseract_cache.py"],
      )
      assert (outdir / "000001_ocr_hocr.hocr").exists()
      hocr = (outdir / "000001_ocr_hocr.hocr").read_text(
          encoding="utf-8"
      )
      mangled = hocr.replace("the", "hocr")
      (outdir / "000001_ocr_hocr.hocr").write_text(
          mangled, encoding="utf-8"
      )
  
      ocrmypdf.api._hocr_to_ocr_pdf(outdir, outpdf, optimize=0)
  
      text = extract_text(outpdf)
      assert "hocr" in text and "the" not in text
  
file_path: OCRmyPDF/tests/test_api.py
imports: from __future__ import annotations
  from io import BytesIO
  from pathlib import Path
  import pytest
  from pdfminer.high_level import extract_text
  import ocrmypdf
  import ocrmypdf.api
label_desc: Use image node_id 4 for calling a global function with example usage: test_hocr_to_pdf_api(resources, outdir, outpdf) without return types