code: def _check_output(cmd, *popenargs, **kwargs):
      """Makes a call to `subprocess.check_output` for the given command and args.
  
      Args:
          cmd:
          *popenargs:
          **kwargs:
      """
      if isinstance(cmd, str):
          cmd = shlex.split(cmd)
  
      success = True
      try:
          output = subprocess.check_output(cmd, *popenargs, **kwargs)
      except subprocess.CalledProcessError as e:
          output = e.output
          success = False
  
      output = output.decode("utf-8")
      if not success:
          logger.error("Command output: %s", output)
          raise Exception("Failed to run %s" % ",".join(cmd))
  
      return output
  
imports: from __future__ import absolute_import, annotations
  import base64
  import copy
  import errno
  import json
  import logging
  import os
  import platform
  import random
  import re
  import shlex
  import shutil
  import string
  import subprocess
  import sys
  import tarfile
  import tempfile
  from distutils.spawn import find_executable
  from threading import Thread
  from typing import Dict, List
  from six.moves.urllib.parse import urlparse
  import sagemaker
  from sagemaker.config.config_schema import CONTAINER_CONFIG, LOCAL
  import sagemaker.local.data
  import sagemaker.local.utils
  import sagemaker.utils
label_desc: Use image node_id 2 for calling a global function with example usage: _check_output(cmd) and returns: output