code: def add_options(parser):
      tess = parser.add_argument_group(
          "Tesseract", "Advanced control of Tesseract OCR"
      )
      tess.add_argument(
          "--tesseract-config",
          action="append",
          metavar="CFG",
          default=[],
          help="Additional Tesseract configuration files -- see documentation.",
      )
      tess.add_argument(
          "--tesseract-pagesegmode",
          action="store",
          type=int,
          metavar="PSM",
          choices=range(0, 14),
          help="Set Tesseract page segmentation mode (see tesseract --help).",
      )
      tess.add_argument(
          "--tesseract-oem",
          action="store",
          type=int,
          metavar="MODE",
          choices=range(0, 4),
          help=(
              "Set Tesseract 4+ OCR engine mode: "
              "0 - original Tesseract only; "
              "1 - neural nets LSTM only; "
              "2 - Tesseract + LSTM; "
              "3 - default."
          ),
      )
      tess.add_argument(
          "--tesseract-thresholding",
          action="store",
          type=str_to_int(tesseract.TESSERACT_THRESHOLDING_METHODS),
          default="auto",
          metavar="METHOD",
          help=(
              "Set Tesseract 5.0+ input image thresholding mode. This may improve OCR "
              "results on low quality images or those that contain high contrast color. "
              "legacy-otsu is the Tesseract default; adaptive-otsu is an improved Otsu "
              "algorithm with improved sort for background color changes; sauvola is "
              "based on local standard deviation."
          ),
      )
      tess.add_argument(
          "--tesseract-timeout",
          default=180.0,
          type=numeric(float, 0),
          metavar="SECONDS",
          help=(
              "Give up on OCR after the timeout, but copy the preprocessed page "
              "into the final output. This timeout is only used when using Tesseract "
              "for OCR. When Tesseract is used for other operations such as "
              "deskewing and orientation, the timeout is controlled by "
              "--tesseract-non-ocr-timeout."
          ),
      )
      tess.add_argument(
          "--tesseract-non-ocr-timeout",
          default=180.0,
          type=numeric(float, 0),
          metavar="SECONDS",
          help=(
              "Give up on non-OCR operations such as deskewing and orientation "
              "after timeout. This is a separate timeout from --tesseract-timeout "
              "because these operations are not as expensive as OCR."
          ),
      )
      tess.add_argument(
          "--tesseract-downsample-large-images",
          action="store_true",
          help=(
              "Downsample large images before OCR. Tesseract has an upper limit on the "
              "size images it will support. If this argument is given, OCRmyPDF will "
              "downsample large images to fit Tesseract. This may reduce OCR quality, "
              "on large images the most desirable text is usually larger. If this "
              "parameter is not supplied, Tesseract will error out and produce no OCR "
              "on the page in question. This argument should be used with a high value "
              "of --tesseract-timeout to ensure Tesseract has enough to time."
          ),
      )
      tess.add_argument(
          "--tesseract-downsample-above",
          action="store",
          type=numeric(int, 100, 32767),
          default=32767,
          help=(
              "Downsample images larger than this size pixel size in either dimension "
              "before OCR. --tesseract-downsample-large-images downsamples only when "
              "an image exceeds Tesseract's internal limits. This argument causes "
              "downsampling to occur when an image exceeds the given size. This may "
              "reduce OCR quality, but on large images the most desirable text is "
              "usually larger."
          ),
      )
      tess.add_argument(
          "--user-words",
          metavar="FILE",
          help="Specify the location of the Tesseract user words file. This is a "
          "list of words Tesseract should consider while performing OCR in "
          "addition to its standard language dictionaries. This can improve "
          "OCR quality especially for specialized and technical documents.",
      )
      tess.add_argument(
          "--user-patterns",
          metavar="FILE",
          help="Specify the location of the Tesseract user patterns file.",
      )
  
imports: from __future__ import annotations
  import logging
  import os
  from PIL import Image
  from ocrmypdf import hookimpl
  from ocrmypdf._exec import tesseract
  from ocrmypdf._jobcontext import PageContext
  from ocrmypdf.cli import numeric, str_to_int
  from ocrmypdf.helpers import clamp
  from ocrmypdf.imageops import calculate_downsample, downsample_image
  from ocrmypdf.pluginspec import OcrEngine
  from ocrmypdf.subprocess import check_external_program
label_desc: Use image node_id 1 for calling a global function with example usage: add_options(parser) without return types