code: def parse_args(args: List[str]) -> Tuple[List[str], List[str], bool]:
      # Manually extract anything before the first "--" to pass through to horovodrun.
      if "--" in args:
          split = args.index("--")
          hvd_args = args[:split]
          args = args[split + 1 :]
      else:
          hvd_args = []
  
      # Then parse the rest of the commands normally.
      parser = argparse.ArgumentParser(
          usage="%(prog)s [[HVD_OVERRIDES...] --] (--trial TRIAL)|(SCRIPT...)",
          description=(
              "Launch a script under horovodrun on a Determined cluster, with automatic handling of "
              "IP addresses, sshd containers, and shutdown mechanics."
          ),
          epilog=(
              "HVD_OVERRIDES may be a list of arguments to pass directly to horovodrun to override "
              "the values set by Determined automatically.  When provided, the list of override "
              "arguments must be terminated by a `--` argument."
          ),
      )
      # For legacy Trial classes.
      parser.add_argument(
          "--trial",
          help=(
              "use a Trial class as the entrypoint to training.  When --trial is used, the SCRIPT "
              "positional argument must be omitted."
          ),
      )
      # For training scripts.
      parser.add_argument(
          "script",
          metavar="SCRIPT...",
          nargs=argparse.REMAINDER,
          help="script to launch for training",
      )
  
      # --autohorovod is an internal-only flag.  What it does is it causes the code skip the
      # horovodrun wrapper when slots_per_trial <= 1.  This has two effects:
      # 1. the execution stack for non-distributed training is simpler, because horovodrun would only
      #    add complexity, and
      # 2. the training code becomes more complex because it has to be aware of multi-vs-single-slot
      #    configuration and avoiding using horovod in the single-slot case.
      # In Determined-owned training loops, we pay the code complexity cost so that the execution of
      # single-slot training stays as simple as possible.  Determined users should not have to pay for
      # dtrain if they don't use it.  However, if a user is writing a custom horovod-based training
      # script and using this det.launch.horovod module as their launch layer, presumably they are
      # already comfortable with horovod and they are not likely to want to pay the code complexity
      # cost.  That is why this flag is internal; we don't really expect any users to ever use it.
      parser.add_argument(
          "--autohorovod", action="store_true", help=argparse.SUPPRESS
      )
  
      parsed = parser.parse_args(args)
  
      script = parsed.script or []
  
      if parsed.trial is not None:
          if script:
              # When --trial is set, any other args are an error.
              parser.print_usage()
              print(
                  "error: extra arguments to --trial:",
                  script,
                  file=sys.stderr,
              )
              sys.exit(1)
          script = det.util.legacy_trial_entrypoint_to_script(
              parsed.trial
          )
      elif not script:
          # There needs to be at least one script argument.
          parser.print_usage()
          print("error: empty script is not allowed", file=sys.stderr)
          sys.exit(1)
  
      return hvd_args, script, parsed.autohorovod
  
file_path: determined/harness/determined/launch/horovod.py
imports: import argparse
  import logging
  import os
  import subprocess
  import sys
  import time
  from typing import List, Tuple
  import determined
  from determined import horovod, util
  from determined.common import api
  from determined.common.api import certs
  from determined.constants import DTRAIN_SSH_PORT
label_desc: Use image node_id 5 for calling a global function with example usage: parse_args(args) and returns: hvd_args,  script,  parsed