code: def _get_parser():
      logging_args = argparse.ArgumentParser(add_help=False)
      logging_args.add_argument(
          "-v", "--verbose", action="count", default=0
      )
      logging_args.add_argument("-l", "--logfile")
  
      parser = argparse.ArgumentParser(
          description="ATM Command Line Interface",
          parents=[logging_args],
      )
  
      subparsers = parser.add_subparsers(
          title="action", help="Action to perform"
      )
      parser.set_defaults(action=None)
  
      # Common Arguments
      sql_args = SQLConfig.get_parser()
      aws_args = AWSConfig.get_parser()
      log_args = LogConfig.get_parser()
      run_args = RunConfig.get_parser()
      dataset_args = DatasetConfig.get_parser()
  
      # Enter Data Parser
      enter_data_parents = [
          logging_args,
          sql_args,
          aws_args,
          dataset_args,
          log_args,
          run_args,
      ]
      enter_data = subparsers.add_parser(
          "enter_data",
          parents=enter_data_parents,
          help="Add a Dataset and trigger a Datarun on it.",
      )
      enter_data.set_defaults(action=_enter_data)
  
      # Wroker Args
      worker_args = argparse.ArgumentParser(add_help=False)
      worker_args.add_argument(
          "--cloud-mode",
          action="store_true",
          default=False,
          help="Whether to run this worker in cloud mode",
      )
      worker_args.add_argument(
          "--no-save",
          dest="save_files",
          action="store_false",
          help="don't save models and metrics at all",
      )
  
      # Worker
      worker_parents = [
          logging_args,
          worker_args,
          sql_args,
          aws_args,
          log_args,
      ]
      worker = subparsers.add_parser(
          "worker",
          parents=worker_parents,
          help="Start a single worker in foreground.",
      )
      worker.set_defaults(action=_work)
      worker.add_argument(
          "--dataruns",
          help="Only train on dataruns with these ids",
          nargs="+",
      )
      worker.add_argument(
          "--total-time",
          help="Number of seconds to run worker",
          type=int,
      )
  
      # Server Args
      server_args = argparse.ArgumentParser(add_help=False)
      server_args.add_argument("--host", help="IP to listen at")
      server_args.add_argument(
          "--port", help="Port to listen at", type=int
      )
  
      # Server
      server = subparsers.add_parser(
          "server",
          parents=[logging_args, server_args, sql_args],
          help="Start the REST API Server in foreground.",
      )
      server.set_defaults(action=_serve)
      server.add_argument(
          "--debug", help="Start in debug mode", action="store_true"
      )
      # add_arguments_sql(server)
  
      # Background Args
      background_args = argparse.ArgumentParser(add_help=False)
      background_args.add_argument(
          "--pid", help="PID file to use.", default="atm.pid"
      )
  
      # Start Args
      start_args = argparse.ArgumentParser(add_help=False)
      start_args.add_argument(
          "--foreground", action="store_true", help="Run on foreground"
      )
      start_args.add_argument(
          "-w",
          "--workers",
          default=1,
          type=int,
          help="Number of workers",
      )
      start_args.add_argument(
          "--no-server",
          dest="server",
          action="store_false",
          help="Do not start the REST server",
      )
  
      # Start
      start_parents = [
          logging_args,
          worker_args,
          server_args,
          background_args,
          start_args,
          sql_args,
          aws_args,
          log_args,
      ]
      start = subparsers.add_parser(
          "start",
          parents=start_parents,
          help="Start an ATM Local Cluster.",
      )
      start.set_defaults(action=_start)
  
      # Status
      status = subparsers.add_parser(
          "status", parents=[logging_args, background_args]
      )
      status.set_defaults(action=_status)
  
      # Stop Args
      stop_args = argparse.ArgumentParser(add_help=False)
      stop_args.add_argument(
          "-t",
          "--timeout",
          default=5,
          type=int,
          help="Seconds to wait before killing the process.",
      )
      stop_args.add_argument(
          "-f",
          "--force",
          action="store_true",
          help="Kill the process if it does not terminate gracefully.",
      )
  
      # Stop
      stop = subparsers.add_parser(
          "stop",
          parents=[logging_args, stop_args, background_args],
          help="Stop an ATM Local Cluster.",
      )
      stop.set_defaults(action=_stop)
  
      # restart
      restart = subparsers.add_parser(
          "restart",
          parents=start_parents + [stop_args],
          help="Restart an ATM Local Cluster.",
      )
      restart.set_defaults(action=_restart)
  
      # Make Config
      make_config = subparsers.add_parser(
          "make_config",
          parents=[logging_args],
          help="Generate a config templates folder in the cwd.",
      )
      make_config.set_defaults(action=_make_config)
  
      # Get Demos
      get_demos = subparsers.add_parser(
          "get_demos",
          parents=[logging_args],
          help="Print a list with the available demo datasets.",
      )
      get_demos.set_defaults(action=_get_demos)
      download_demo = subparsers.add_parser(
          "download_demo",
          parents=[logging_args],
          help="Downloads a demo dataset from AWS3.",
      )
      download_demo.set_defaults(action=_download_demo)
      download_demo.add_argument(
          "dataset",
          nargs="+",
          help="Name of the dataset to be downloaded.",
      )
      download_demo.add_argument(
          "--path", help="Directory to be used to store the dataset."
      )
  
      return parser
  
imports: import argparse
  import logging
  import multiprocessing
  import os
  import time
  import psutil
  from daemon import DaemonContext
  from lockfile.pidlockfile import PIDLockFile
  from atm.api import create_app
  from atm.config import AWSConfig, DatasetConfig, LogConfig, RunConfig, SQLConfig
  from atm.core import ATM
  from atm.data import copy_files, download_demo, get_demos
label_desc: Use image node_id 15 for calling a global function with example usage: _get_parser() and returns: parser