code: def get_args_parser() -> ArgumentParser:
      """Parse the command line options."""
      parser = ArgumentParser(
          description="Torch Distributed Elastic Training Launcher"
      )
  
      #
      # Worker/node size related arguments.
      #
  
      parser.add_argument(
          "--nnodes",
          action=env,
          type=str,
          default="1:1",
          help="Number of nodes, or the range of nodes in form <minimum_nodes>:<maximum_nodes>.",
      )
      parser.add_argument(
          "--nproc-per-node",
          "--nproc_per_node",
          action=env,
          type=str,
          default="1",
          help="Number of workers per node; supported values: [auto, cpu, gpu, int].",
      )
  
      #
      # Rendezvous related arguments
      #
  
      parser.add_argument(
          "--rdzv-backend",
          "--rdzv_backend",
          action=env,
          type=str,
          default="static",
          help="Rendezvous backend.",
      )
      parser.add_argument(
          "--rdzv-endpoint",
          "--rdzv_endpoint",
          action=env,
          type=str,
          default="",
          help="Rendezvous backend endpoint; usually in form <host>:<port>.",
      )
      parser.add_argument(
          "--rdzv-id",
          "--rdzv_id",
          action=env,
          type=str,
          default="none",
          help="User-defined group id.",
      )
      parser.add_argument(
          "--rdzv-conf",
          "--rdzv_conf",
          action=env,
          type=str,
          default="",
          help="Additional rendezvous configuration (<key1>=<value1>,<key2>=<value2>,...).",
      )
      parser.add_argument(
          "--standalone",
          action=check_env,
          help="Start a local standalone rendezvous backend that is represented by a C10d TCP store "
          "on a free port. Useful when launching single-node, multi-worker job. If specified "
          "--rdzv-backend, --rdzv-endpoint, --rdzv-id are auto-assigned and any explicitly set values "
          "are ignored.",
      )
  
      #
      # User-code launch related arguments.
      #
  
      parser.add_argument(
          "--max-restarts",
          "--max_restarts",
          action=env,
          type=int,
          default=0,
          help="Maximum number of worker group restarts before failing.",
      )
      parser.add_argument(
          "--monitor-interval",
          "--monitor_interval",
          action=env,
          type=float,
          default=5,
          help="Interval, in seconds, to monitor the state of workers.",
      )
      parser.add_argument(
          "--start-method",
          "--start_method",
          action=env,
          type=str,
          default="spawn",
          choices=["spawn", "fork", "forkserver"],
          help="Multiprocessing start method to use when creating workers.",
      )
      parser.add_argument(
          "--role",
          action=env,
          type=str,
          default="default",
          help="User-defined role for the workers.",
      )
      parser.add_argument(
          "-m",
          "--module",
          action=check_env,
          help="Change each process to interpret the launch script as a Python module, executing "
          "with the same behavior as 'python -m'.",
      )
      parser.add_argument(
          "--no-python",
          "--no_python",
          action=check_env,
          help="Skip prepending the training script with 'python' - just execute it directly. Useful "
          "when the script is not a Python script.",
      )
  
      parser.add_argument(
          "--run-path",
          "--run_path",
          action=check_env,
          help="Run the training script with runpy.run_path in the same interpreter."
          " Script must be provided as an abs path (e.g. /abs/path/script.py)."
          " Takes precedence over --no-python.",
      )
      parser.add_argument(
          "--log-dir",
          "--log_dir",
          action=env,
          type=str,
          default=None,
          help="Base directory to use for log files (e.g. /var/log/torch/elastic). The same "
          "directory is re-used for multiple runs (a unique job-level sub-directory is created with "
          "rdzv_id as the prefix).",
      )
      parser.add_argument(
          "-r",
          "--redirects",
          action=env,
          type=str,
          default="0",
          help="Redirect std streams into a log file in the log directory (e.g. [-r 3] redirects "
          "both stdout+stderr for all workers, [-r 0:1,1:2] redirects stdout for local rank 0 and "
          "stderr for local rank 1).",
      )
      parser.add_argument(
          "-t",
          "--tee",
          action=env,
          type=str,
          default="0",
          help="Tee std streams into a log file and also to console (see --redirects for format).",
      )
  
      #
      # Backwards compatible parameters with caffe2.distributed.launch.
      #
  
      parser.add_argument(
          "--node-rank",
          "--node_rank",
          type=int,
          action=env,
          default=0,
          help="Rank of the node for multi-node distributed training.",
      )
      parser.add_argument(
          "--master-addr",
          "--master_addr",
          default="127.0.0.1",
          type=str,
          action=env,
          help="Address of the master node (rank 0) that only used for static rendezvous. It should "
          "be either the IP address or the hostname of rank 0. For single node multi-proc training "
          "the --master-addr can simply be 127.0.0.1; IPv6 should have the pattern "
          "`[0:0:0:0:0:0:0:1]`.",
      )
      parser.add_argument(
          "--master-port",
          "--master_port",
          default=29500,
          type=int,
          action=env,
          help="Port on the master node (rank 0) to be used for communication during distributed "
          "training. It is only used for static rendezvous.",
      )
      parser.add_argument(
          "--local-addr",
          "--local_addr",
          default=None,
          type=str,
          action=env,
          help="Address of the local node. If specified, will use the given address for connection. "
          "Else, will look up the local node address instead. Else, it will be default to local "
          "machine's FQDN.",
      )
  
      #
      # Positional arguments.
      #
  
      parser.add_argument(
          "training_script",
          type=str,
          help="Full path to the (single GPU) training program/script to be launched in parallel, "
          "followed by all the arguments for the training script.",
      )
  
      # Rest from the training program.
      parser.add_argument("training_script_args", nargs=REMAINDER)
  
      return parser
  
imports: import logging
  import os
  import sys
  import uuid
  from argparse import REMAINDER, ArgumentParser
  from typing import Callable, List, Tuple, Union
  import torch
  from torch.distributed.argparse_util import check_env, env
  from torch.distributed.elastic.multiprocessing import Std
  from torch.distributed.elastic.multiprocessing.errors import record
  from torch.distributed.elastic.rendezvous.utils import _parse_rendezvous_config
  from torch.distributed.elastic.utils import macros
  from torch.distributed.elastic.utils.logging import get_logger
  from torch.distributed.launcher.api import LaunchConfig, elastic_launch
  from torch.utils.backend_registration import _get_custom_mod_func
label_desc: Use image node_id 1 for calling a global function with example usage: get_args_parser() and returns: parser