code: def validate(pdfinfo, options):
      # Tesseract 4.x can be multithreaded, and we also run multiple workers. We want
      # to manage how many threads it uses to avoid creating total threads than cores.
      # Performance testing shows we're better off
      # parallelizing ocrmypdf and forcing Tesseract to be single threaded, which we
      # get by setting the envvar OMP_THREAD_LIMIT to 1. But if the page count of the
      # input file is small, then we allow Tesseract to use threads, subject to the
      # constraint: (ocrmypdf workers) * (tesseract threads) <= max_workers.
      # As of Tesseract 4.1, 3 threads is the most effective on a 4 core/8 thread system.
      if not os.environ.get("OMP_THREAD_LIMIT", "").isnumeric():
          tess_threads = clamp(options.jobs // len(pdfinfo), 1, 3)
          os.environ["OMP_THREAD_LIMIT"] = str(tess_threads)
      else:
          tess_threads = int(os.environ["OMP_THREAD_LIMIT"])
      log.debug("Using Tesseract OpenMP thread limit %d", tess_threads)
  
      if (
          options.tesseract_downsample_above != 32767
          and not options.tesseract_downsample_large_images
      ):
          log.warning(
              "The --tesseract-downsample-above argument will have no effect unless "
              "--tesseract-downsample-large-images is also given."
          )
  
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 3 for calling a global function with example usage: validate(pdfinfo, options) without return types