code: def create_options(
      *,
      input_file: PathOrIO,
      output_file: PathOrIO,
      parser: ArgumentParser,
      **kwargs,
  ) -> Namespace:
      """Construct an options object from the input/output files and keyword arguments.
  
      Args:
          input_file: Input file path or file object.
          output_file: Output file path or file object.
          parser: ArgumentParser object.
          **kwargs: Keyword arguments.
  
      Returns:
          argparse.Namespace: A Namespace object containing the parsed arguments.
  
      Raises:
          TypeError: If the type of a keyword argument is not supported.
      """
      cmdline, deferred = _kwargs_to_cmdline(
          defer_kwargs={
              "progress_bar",
              "plugins",
              "parser",
              "input_file",
              "output_file",
          },
          **kwargs,
      )
      if isinstance(input_file, (BinaryIO, IOBase)):
          cmdline.append("stream://input_file")
      else:
          cmdline.append(os.fspath(input_file))
      if isinstance(output_file, (BinaryIO, IOBase)):
          cmdline.append("stream://output_file")
      else:
          cmdline.append(os.fspath(output_file))
  
      parser.enable_api_mode()
      options = parser.parse_args(cmdline)
      for keyword, val in deferred.items():
          setattr(options, keyword, val)
  
      if options.input_file == "stream://input_file":
          options.input_file = input_file
      if options.output_file == "stream://output_file":
          options.output_file = output_file
  
      return options
  
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 3 for calling a global function with example usage: create_options() and returns: options