code: def run_ocrmypdf_api(
      input_file: Path, output_file: Path, *args
  ) -> ExitCode:
      """Run ocrmypdf via its API in-process, but return CLI-style ExitCode.
  
      This simulates calling the command line interface in a subprocess and allows us
      to check that the command line interface is working correctly, but since it is
      in-process it is easier to trace with a debugger or coverage tool.
  
      Any exception raised will be trapped and converted to an exit code.
      The return code must be checked by the caller to determine if the test passed.
      """
      api_args = [str(input_file), str(output_file)] + [
          str(arg) for arg in args if arg is not None
      ]
      _parser, options, plugin_manager = get_parser_options_plugins(
          args=api_args
      )
  
      api.check_options(options, plugin_manager)
      return api.run_pipeline_cli(
          options, plugin_manager=plugin_manager
      )
  
imports: from __future__ import annotations
  import platform
  import sys
  from pathlib import Path
  from subprocess import CompletedProcess, run
  import pytest
  from ocrmypdf import api, pdfinfo
  from ocrmypdf._exec import unpaper
  from ocrmypdf._plugin_manager import get_parser_options_plugins
  from ocrmypdf.exceptions import ExitCode
label_desc: Use image node_id 13 for calling a global function with example usage: run_ocrmypdf_api(input_file, output_file) and returns: api