code: def str_to_int(mapping: Mapping[str, int]):
      """Accept text on command line and convert to integer."""
  
      def _str_to_int(s: str) -> int:
          try:
              return mapping[s]
          except KeyError:
              raise argparse.ArgumentTypeError(
                  f"{s!r} must be one of: {', '.join(mapping.keys())}"
              ) from None
  
      return _str_to_int
  
file_path: OCRmyPDF/src/ocrmypdf/cli.py
imports: from __future__ import annotations
  import argparse
  from collections.abc import Mapping
  from typing import Any, Callable, TypeVar
  from ocrmypdf._version import PROGRAM_NAME
  from ocrmypdf._version import __version__
label_desc: Use image node_id 2 for calling a global function with example usage: str_to_int(mapping) and returns: _str_to_int, mapping