code: def run_unpaper(
      input_file: Path,
      output_file: Path,
      *,
      dpi: DecFloat,
      mode_args: list[str],
  ) -> None:
      args_unpaper = [
          "unpaper",
          "-v",
          "--dpi",
          str(round(dpi, 6)),
      ] + mode_args
  
      with _setup_unpaper_io(input_file) as (
          input_png,
          output_pnm,
          tmpdir,
      ):
          # To prevent any shenanigans from accepting arbitrary parameters in
          # --unpaper-args, we:
          # 1) run with cwd set to a tmpdir with only unpaper's files
          # 2) forbid the use of '/' in arguments, to prevent changing paths
          # 3) append absolute paths for the input and output file
          # This should ensure that a user cannot clobber some other file with
          # their unpaper arguments (whether intentionally or otherwise)
          args_unpaper.extend(
              [os.fspath(input_png), os.fspath(output_pnm)]
          )
          run(
              args_unpaper,
              close_fds=True,
              check=True,
              stderr=STDOUT,  # unpaper writes logging output to stdout and stderr
              stdout=PIPE,  # and cannot send file output to stdout
              cwd=tmpdir,
              logs_errors_to_stdout=True,
          )
          try:
              with Image.open(output_pnm) as imout:
                  imout.save(output_file, dpi=(dpi, dpi))
          except OSError as e:
              raise SubprocessOutputError(
                  "unpaper: failed to produce the expected output file. "
                  + " Called with: "
                  + str(args_unpaper)
              ) from e
  
imports: from __future__ import annotations
  import logging
  import os
  import shlex
  import sys
  from collections.abc import Iterator
  from contextlib import contextmanager
  from decimal import Decimal
  from pathlib import Path
  from subprocess import PIPE, STDOUT
  from tempfile import TemporaryDirectory
  from typing import Union
  from packaging.version import Version
  from PIL import Image
  from ocrmypdf.exceptions import MissingDependencyError, SubprocessOutputError
  from ocrmypdf.subprocess import get_version, run
label_desc: Use image node_id 3 for calling a global function with example usage: run_unpaper(input_file, output_file) without return types