code: def convert_single_page(
      doc,
      pnum,
      tess_lang: str,
      spell_lang: Optional[str],
      no_text: bool,
      disable_ocr: bool = False,
      min_ocr_page: int = 2,
  ):
      ocr_pages = 0
      ocr_success = 0
      ocr_failed = 0
      spellchecker = None
      page_bbox = doc[pnum].bound()
      if spell_lang:
          spellchecker = SpellChecker(language=spell_lang)
  
      blocks = get_single_page_blocks(
          doc, pnum, tess_lang, spellchecker
      )
      page_obj = Page(blocks=blocks, pnum=pnum, bbox=page_bbox)
  
      # OCR page if we got minimal text, or if we got too many spaces
      conditions = [
          (
              no_text  # Full doc has no text, and needs full OCR
              or (
                  len(page_obj.prelim_text) > 0
                  and detect_bad_ocr(page_obj.prelim_text, spellchecker)
              )  # Bad OCR
          ),
          min_ocr_page < pnum < len(doc) - 1,
          not disable_ocr,
      ]
      if all(conditions) or settings.OCR_ALL_PAGES:
          page = doc[pnum]
          blocks = get_single_page_blocks(
              doc, pnum, tess_lang, spellchecker, ocr=True
          )
          page_obj = Page(
              blocks=blocks,
              pnum=pnum,
              bbox=page_bbox,
              rotation=page.rotation,
          )
          ocr_pages = 1
          if len(blocks) == 0:
              ocr_failed = 1
          else:
              ocr_success = 1
      return page_obj, {
          "ocr_pages": ocr_pages,
          "ocr_failed": ocr_failed,
          "ocr_success": ocr_success,
      }
  
file_path: pdf-to-markdown/marker/extract_text.py
imports: import os
  from typing import Tuple, List, Optional
  from spellchecker import SpellChecker
  from marker.bbox import correct_rotation
  from marker.ocr.page import ocr_entire_page
  from marker.ocr.utils import detect_bad_ocr, font_flags_decomposer
  from marker.settings import settings
  from marker.schema import Span, Line, Block, Page
  from concurrent.futures import ThreadPoolExecutor
label_desc: Use image node_id 3 for calling a global function with example usage: convert_single_page(doc, pnum, tess_lang, spell_lang, no_text, disable_ocr, min_ocr_page) and returns: page_obj,  dict