code: def _get_output(cmd: str | Sequence[str]) -> str:
      """Get output of a command, raising IOError if it fails"""
      startupinfo = None
      if os.name == "nt":
          startupinfo = (
              subprocess.STARTUPINFO()
          )  # type:ignore[attr-defined]
          startupinfo.dwFlags |= (
              subprocess.STARTF_USESHOWWINDOW
          )  # type:ignore[attr-defined]
      p = Popen(
          cmd, stdout=PIPE, stderr=PIPE, startupinfo=startupinfo
      )  # noqa
      stdout, stderr = p.communicate()
      if p.returncode:
          msg = "Failed to run {}: {}".format(
              cmd, stderr.decode("utf8", "replace")
          )
          raise OSError(msg)
      return stdout.decode("utf8", "replace")
  
imports: from __future__ import annotations
  import os
  import re
  import socket
  import subprocess
  from subprocess import PIPE, Popen
  from typing import Any, Callable, Iterable, Sequence
  from warnings import warn
label_desc: Use image node_id 2 for calling a global function with example usage: _get_output(cmd) and returns: stdout