code: def merge_sidecars(
      txt_files: Iterable[Path | None], context: PdfContext
  ) -> Path:
      """Merge the page sidecar files into a single file.
  
      Sidecar files are created by the OCR engine and contain the text for each
      page in the PDF. This function merges the sidecar files into a single file
      and returns the path to the merged file.
      """
      output_file = context.get_path("sidecar.txt")
      with open(output_file, "w", encoding="utf-8") as stream:
          for (from_, to_), txt_file in enumerate_compress_ranges(
              txt_files
          ):
              if from_ != 1:
                  stream.write(
                      "\f"
                  )  # Form feed between pages for all pages after first
              if txt_file:
                  txt = txt_file.read_text(encoding="utf-8")
                  # Some versions of Tesseract add a form feed at the end and
                  # others don't. Remove it if it exists, since we add one manually.
                  stream.write(txt.removesuffix("\f"))
              else:
                  if from_ != to_:
                      pages = f"{from_}-{to_}"
                  else:
                      pages = f"{from_}"
                  stream.write(f"[OCR skipped on page(s) {pages}]")
      return output_file
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import sys
  from collections.abc import Iterable, Iterator, Sequence
  from contextlib import suppress
  from pathlib import Path
  from shutil import copyfileobj, copystat
  from typing import Any, BinaryIO, TypeVar, cast
  import img2pdf
  import pikepdf
  from PIL import Image, ImageColor, ImageDraw
  from ocrmypdf._concurrent import Executor
  from ocrmypdf._exec import unpaper
  from ocrmypdf._jobcontext import PageContext, PdfContext
  from ocrmypdf._metadata import repair_docinfo_nuls
  from ocrmypdf.exceptions import DigitalSignatureError, DpiError, EncryptedPdfError, InputFileError, PriorOcrFoundError, TaggedPDFError, UnsupportedImageFormatError
  from ocrmypdf.helpers import IMG2PDF_KWARGS, Resolution, safe_symlink
  from ocrmypdf.hocrtransform import DebugRenderOptions, HocrTransform
  from ocrmypdf.hocrtransform._font import Courier
  from ocrmypdf.pdfa import generate_pdfa_ps
  from ocrmypdf.pdfinfo import Colorspace, Encoding, PageInfo, PdfInfo
  from ocrmypdf.pluginspec import OrientationConfidence
label_desc: Use image node_id 33 for calling a global function with example usage: merge_sidecars(txt_files, context) and returns: output_file