code: def run_commands(
      commands: List[str],
      sequential: bool = True,
      dry_run: bool = False,
  ) -> None:
      """Run commands using subprocess, sequentially or in parallel.
  
      Whether sequential or not, this function will finish when all commands have
      stopped running.
  
      Args:
        commands: List of string commands to run, to be executed by /bin/bash.
        sequential: True to execute commands one at a time, exiting if any fail.
          False to run all in parallel, exiting when all have succeeded or failed.
        dry_run: False to execute commands, True to only print commands.
  
      Raises:
        Exception: When one or more of the given commands have failed.
      """
  
      if sequential:
          for command in commands:
              print(
                  "\n***** Running the command:*****\n{}\n".format(
                      command
                  )
              )
              if not dry_run:
                  try:
                      subprocess.check_call(
                          command, shell=True, executable="/bin/bash"
                      )
                  except subprocess.CalledProcessError as e:
                      logging.info(e.output)
                      raise ValueError(
                          "Command(s) failed. See details above."
                      ) from e
      else:
          for command in commands:
              print(
                  "\n***** Running the command:*****\n{}\n".format(
                      command
                  )
              )
          if not _DRY_RUN.value:
              tasks = [
                  subprocess.Popen(
                      command, shell=True, executable="/bin/bash"
                  )
                  for command in commands
              ]
              failed_task_indices = [
                  i for i, task in enumerate(tasks) if task.wait() != 0
              ]
              if failed_task_indices:
                  for i in failed_task_indices:
                      logging.info("Failed command: %s", commands[i])
                  raise ValueError(
                      "Command(s) failed. See details above."
                  )
  
imports: import enum
  import os
  import subprocess
  import sys
  import tempfile
  from typing import List, Optional
  from absl import app
  from absl import flags
  from absl import logging
  import tensorflow
label_desc: Use image node_id 27 for calling a global function with example usage: run_commands(commands, sequential, dry_run) without return types