code: def _kwargs_to_cmdline(
      *, defer_kwargs: set[str], **kwargs
  ) -> tuple[list[str], dict[str, AnyStr]]:
      """Convert kwargs to command line arguments."""
      cmdline = []
      deferred = {}
      for arg, val in kwargs.items():
          if val is None:
              continue
  
          # Skip arguments that are handled elsewhere
          if arg in defer_kwargs:
              deferred[arg] = val
              continue
  
          cmd_style_arg = arg.replace("_", "-")
  
          # Booleans are special: add only if True, omit for False
          if isinstance(val, bool):
              if val:
                  cmdline.append(f"--{cmd_style_arg}")
              continue
  
          if is_iterable_notstr(val):
              for elem in val:
                  cmdline.append(f"--{cmd_style_arg}")
                  cmdline.append(elem)
              continue
  
          # We have a parameter
          cmdline.append(f"--{cmd_style_arg}")
          if isinstance(val, (int, float)):
              cmdline.append(str(val))
          elif isinstance(val, str):
              cmdline.append(val)
          elif isinstance(val, Path):
              cmdline.append(str(val))
          else:
              raise TypeError(f"{arg}: {val} ({type(val)})")
      return cmdline, deferred
  
imports: from __future__ import annotations
  import logging
  import os
  import sys
  import threading
  from argparse import Namespace
  from collections.abc import Iterable, Sequence
  from enum import IntEnum
  from io import IOBase
  from pathlib import Path
  from typing import AnyStr, BinaryIO, Union
  from warnings import warn
  import pluggy
  from ocrmypdf._logging import PageNumberFilter
  from ocrmypdf._pipelines.hocr_to_ocr_pdf import run_hocr_to_ocr_pdf_pipeline
  from ocrmypdf._pipelines.ocr import run_pipeline, run_pipeline_cli
  from ocrmypdf._pipelines.pdf_to_hocr import run_hocr_pipeline
  from ocrmypdf._plugin_manager import get_plugin_manager
  from ocrmypdf._validation import check_options
  from ocrmypdf.cli import ArgumentParser, get_parser
  from ocrmypdf.helpers import is_iterable_notstr
label_desc: Use image node_id 2 for calling a global function with example usage: _kwargs_to_cmdline() and returns: cmdline,  deferred