code: def run(
      args: Args,
      *,
      env: OsEnviron | None = None,
      logs_errors_to_stdout: bool = False,
      check: bool = False,
      **kwargs,
  ) -> CompletedProcess:
      """Wrapper around :py:func:`subprocess.run`.
  
      The main purpose of this wrapper is to log subprocess output in an orderly
      fashion that identifies the responsible subprocess. An additional
      task is that this function goes to greater lengths to find possible Windows
      locations of our dependencies when they are not on the system PATH.
  
      Arguments should be identical to ``subprocess.run``, except for following:
  
      Args:
          args: Positional arguments to pass to ``subprocess.run``.
          env: A set of environment variables. If None, the OS environment is used.
          logs_errors_to_stdout: If True, indicates that the process writes its error
              messages to stdout rather than stderr, so stdout should be logged
              if there is an error. If False, stderr is logged. Could be used with
              stderr=STDOUT, stdout=PIPE for example.
          check: If True, raise an exception if the process exits with a non-zero
              status code. If False, the return value will indicate success or failure.
          kwargs: Additional arguments to pass to ``subprocess.run``.
      """
      args, env, process_log, _text = _fix_process_args(
          args, env, kwargs
      )
  
      stderr = None
      stderr_name = "stderr" if not logs_errors_to_stdout else "stdout"
      try:
          proc = subprocess_run(args, env=env, check=check, **kwargs)
      except CalledProcessError as e:
          stderr = getattr(e, stderr_name, None)
          raise
      else:
          stderr = getattr(proc, stderr_name, None)
      finally:
          if process_log.isEnabledFor(logging.DEBUG) and stderr:
              with suppress(AttributeError, UnicodeDecodeError):
                  stderr = stderr.decode("utf-8", "replace")
              if logs_errors_to_stdout:
                  process_log.debug("stdout/stderr = %s", stderr)
              else:
                  process_log.debug("stderr = %s", stderr)
      return proc
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import sys
  from collections.abc import Mapping, Sequence
  from contextlib import suppress
  from pathlib import Path
  from subprocess import PIPE, STDOUT, CalledProcessError, CompletedProcess, Popen
  from subprocess import run
  from typing import Callable, Union
  from packaging.version import Version
  from ocrmypdf.exceptions import MissingDependencyError
label_desc: Use image node_id 1 for calling a global function with example usage: run(args) and returns: proc