code: def run_cli(
      args: List[str],
      hide_output: bool = False,
  ) -> str:
      """
      Runs the Cortex binary with the specified arguments.
  
      Args:
          args: Arguments to use when invoking the Cortex CLI.
          hide_output: Flag to prevent streaming CLI output to stdout.
  
      Raises:
          CortexBinaryException: Cortex CLI command returned an error.
  
      Returns:
          The stdout from the Cortex CLI command.
      """
  
      env = os.environ.copy()
      env["CORTEX_CLI_INVOKER"] = "python"
      if "AWS_VPC_K8S_CNI_LOG_FILE" not in env:
          env["AWS_VPC_K8S_CNI_LOG_FILE"] = "/dev/null"
      process = subprocess.Popen(
          [get_cli_path()] + args,
          stderr=subprocess.PIPE,
          stdout=subprocess.PIPE,
          encoding="utf8",
          env=env,
      )
  
      output = ""
      result = ""
  
      for c in iter(lambda: process.stdout.read(1), ""):
          output += c
  
          if not hide_output:
              sys.stdout.write(c)
              sys.stdout.flush()
  
      process.wait()
  
      if process.returncode == 0:
          return output
  
      if result != "":
          raise CortexBinaryException(
              result + "\n" + process.stderr.read()
          )
  
      raise CortexBinaryException(process.stderr.read())
  
file_path: cortex/python/client/cortex/binary/__init__.py
imports: import os
  import subprocess
  import sys
  from typing import List
  from cortex.exceptions import CortexBinaryException
label_desc: Use image node_id 2 for calling a global function with example usage: run_cli(args, hide_output) and returns: output