code: def numeric(
      basetype: Callable[[Any], T],
      min_: T | None = None,
      max_: T | None = None,
  ):
      """Validator for numeric command line parameters.
  
      Stipulates that the value must be of type basetype (typically int or float), and
      optionally, within the range [min_, max_].
      """
      min_ = basetype(min_) if min_ is not None else None
      max_ = basetype(max_) if max_ is not None else None
  
      def _numeric(s: str) -> T:
          value = basetype(s)
          if (min_ is not None and value < min_) or (
              max_ is not None and value > max_
          ):
              raise argparse.ArgumentTypeError(
                  f"{s!r} not in valid range {(min_, max_)!r}"
              )
          return value
  
      _numeric.__name__ = basetype.__name__
      return _numeric
  
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 1 for calling a global function with example usage: numeric(basetype, min_, max_) and returns: _numeric, value