code: def run(
      cmd,
      input=None,
      capture_output=False,
      check=False,
      encoding=None,
      quiet=False,
      **kwargs,
  ):
      """Run the command described by cmd and return its (stdout, stderr) tuple."""
      log.debug("run %r", cmd)
  
      if input is not None:
          kwargs["stdin"] = subprocess.PIPE
          if encoding is not None:
              input = input.encode(encoding)
  
      if capture_output:
          kwargs["stdout"] = kwargs["stderr"] = subprocess.PIPE
  
      try:
          proc = subprocess.Popen(
              cmd, startupinfo=get_startupinfo(), **kwargs
          )
      except OSError as e:
          if e.errno == errno.ENOENT:
              raise ExecutableNotFound(cmd)
          else:
              raise
  
      out, err = proc.communicate(input)
  
      if not quiet and err:
          _compat.stderr_write_bytes(err, flush=True)
  
      if encoding is not None:
          if out is not None:
              out = out.decode(encoding)
          if err is not None:
              err = err.decode(encoding)
  
      if check and proc.returncode:
          raise CalledProcessError(
              proc.returncode, cmd, output=out, stderr=err
          )
  
      return out, err
  
imports: import errno
  import logging
  import os
  import platform
  import re
  import subprocess
  from .None import _compat
  from .None import tools
label_desc: Use image node_id 2 for calling a global function with example usage: run(cmd, input, capture_output, check, encoding, quiet) and returns: out,  err