class_docstr: This class is responsible for gathering all user-specified configuration options, parsing them,
  instantiating a GraphManager and then starting that GraphManager with either improve() or evaluate().
  This class is also responsible for launching multiple processes.
  It is structured so that it can be sub-classed to provide alternate mechanisms to configure and launch
  Coach jobs.
  
  The key entry-point for this class is the .launch() method which is expected to be called from __main__
  and handle absolutely everything for a job.
class_docstr_tok: ["This","class","is","responsible","for","gathering","all","user-specified","configuration","options",",","parsing","them",",","instantiating","a","GraphManager","and","then","starting","that","GraphManager","with","either","improve","(",")","or","evaluate","(",")",".","This","class","is","also","responsible","for","launching","multiple","processes",".","It","is","structured","so","that","it","can","be","sub-classed","to","provide","alternate","mechanisms","to","configure","and","launch","Coach","jobs",".","The","key","entry-point","for","this","class","is","the",".launch","(",")","method","which","is","expected","to","be","called","from","__main__","and","handle","absolutely","everything","for","a","job","."]
docstr: Returns a Namespace object with all the user-specified configuration options needed to launch.
  This implementation uses argparse to take arguments from the CLI, but this can be over-ridden by
  another method that gets its configuration from elsewhere.  An equivalent method however must
  return an identically structured Namespace object, which conforms to the structure defined by
  get_argument_parser.
  
  This method parses the arguments that the user entered, does some basic validation, and
  modification of user-specified values in short form to be more explicit.
  
  :param parser: a parser object which implicitly defines the format of the Namespace that
                 is expected to be returned.
  :param arguments: command line arguments
  :return: the parsed arguments as a Namespace
docstr_tok: ["Returns","a","Namespace","object","with","all","the","user-specified","configuration","options","needed","to","launch",".","This","implementation","uses","argparse","to","take","arguments","from","the","CLI",",","but","this","can","be","over-ridden","by","another","method","that","gets","its","configuration","from","elsewhere",".","An","equivalent","method","however","must","return","an","identically","structured","Namespace","object",",","which","conforms","to","the","structure","defined","by","get_argument_parser",".","This","method","parses","the","arguments","that","the","user","entered",",","does","some","basic","validation",",","and","modification","of","user-specified","values","in","short","form","to","be","more","explicit",".",":","param","parser",":","a","parser","object","which","implicitly","defines","the","format","of","the","Namespace","that","is","expected","to","be","returned",".",":","param","arguments",":","command","line","arguments",":","return",":","the","parsed","arguments","as","a","Namespace"]
code: def get_config_args(
      self, parser: argparse.ArgumentParser, arguments=None
  ) -> argparse.Namespace:
      """
      Returns a Namespace object with all the user-specified configuration options needed to launch.
      This implementation uses argparse to take arguments from the CLI, but this can be over-ridden by
      another method that gets its configuration from elsewhere.  An equivalent method however must
      return an identically structured Namespace object, which conforms to the structure defined by
      get_argument_parser.
  
      This method parses the arguments that the user entered, does some basic validation, and
      modification of user-specified values in short form to be more explicit.
  
      :param parser: a parser object which implicitly defines the format of the Namespace that
                     is expected to be returned.
      :param arguments: command line arguments
      :return: the parsed arguments as a Namespace
      """
      if arguments is None:
          args = parser.parse_args()
      else:
          args = parser.parse_args(arguments)
  
      if args.nocolor:
          screen.set_use_colors(False)
  
      # if no arg is given
      if (len(sys.argv) == 1 and arguments is None) or (
          arguments is not None and len(arguments) <= 2
      ):
          parser.print_help()
          sys.exit(1)
  
      # list available presets
      if args.list:
          self.display_all_presets_and_exit()
  
      # Read args from config file for distributed Coach.
      if (
          args.distributed_coach
          and args.distributed_coach_run_type == RunType.ORCHESTRATOR
      ):
          coach_config = ConfigParser(
              {
                  "image": "",
                  "memory_backend": "redispubsub",
                  "data_store": "s3",
                  "s3_end_point": "s3.amazonaws.com",
                  "s3_bucket_name": "",
                  "s3_creds_file": "",
              }
          )
          try:
              coach_config.read(args.distributed_coach_config_path)
              args.image = coach_config.get("coach", "image")
              args.memory_backend = coach_config.get(
                  "coach", "memory_backend"
              )
              args.data_store = coach_config.get("coach", "data_store")
              if args.data_store == "s3":
                  args.s3_end_point = coach_config.get(
                      "coach", "s3_end_point"
                  )
                  args.s3_bucket_name = coach_config.get(
                      "coach", "s3_bucket_name"
                  )
                  args.s3_creds_file = coach_config.get(
                      "coach", "s3_creds_file"
                  )
          except Error as e:
              screen.error(
                  "Error when reading distributed Coach config file: {}".format(
                      e
                  )
              )
  
          if args.image == "":
              screen.error("Image cannot be empty.")
  
          data_store_choices = ["s3", "nfs", "redis"]
          if args.data_store not in data_store_choices:
              screen.warning(
                  "{} data store is unsupported.".format(
                      args.data_store
                  )
              )
              screen.error(
                  "Supported data stores are {}.".format(
                      data_store_choices
                  )
              )
  
          memory_backend_choices = ["redispubsub"]
          if args.memory_backend not in memory_backend_choices:
              screen.warning(
                  "{} memory backend is not supported.".format(
                      args.memory_backend
                  )
              )
              screen.error(
                  "Supported memory backends are {}.".format(
                      memory_backend_choices
                  )
              )
  
          if args.data_store == "s3":
              if args.s3_bucket_name == "":
                  screen.error("S3 bucket name cannot be empty.")
              if args.s3_creds_file == "":
                  args.s3_creds_file = None
  
      if args.play and args.distributed_coach:
          screen.error("Playing is not supported in distributed Coach.")
  
      # replace a short preset name with the full path
      if args.preset is not None:
          args.preset = self.expand_preset(args.preset)
  
      # validate the checkpoints args
      if (
          args.checkpoint_restore_dir is not None
          and not os.path.exists(args.checkpoint_restore_dir)
      ):
          # If distributed trainer, the checkpoint dir is not yet available so skipping the check in that case.
          if not (
              args.distributed_coach
              and args.distributed_coach_run_type
              in [RunType.TRAINER, RunType.ROLLOUT_WORKER]
          ):
              screen.error(
                  "The requested checkpoint folder to load from does not exist."
              )
  
      # validate the checkpoints args
      if args.checkpoint_restore_file is not None and not glob(
          args.checkpoint_restore_file + "*"
      ):
          screen.error(
              "The requested checkpoint file to load from does not exist."
          )
  
      # no preset was given. check if the user requested to play some environment on its own
      if (
          args.preset is None
          and args.play
          and not args.environment_type
      ):
          screen.error(
              "When no preset is given for Coach to run, and the user requests human control over "
              "the environment, the user is expected to input the desired environment_type and level."
              "\nAt least one of these parameters was not given."
          )
      elif args.preset and args.play:
          screen.error(
              "Both the --preset and the --play flags were set. These flags can not be used together. "
              "For human control, please use the --play flag together with the environment type flag (-et)"
          )
      elif args.preset is None and not args.play:
          screen.error(
              "Please choose a preset using the -p flag or use the --play flag together with choosing an "
              "environment type (-et) in order to play the game."
          )
  
      # get experiment name and path
      args.experiment_name = logger.get_experiment_name(
          args.experiment_name
      )
      args.experiment_path = logger.get_experiment_path(
          args.experiment_name, args.experiment_path
      )
  
      if args.play and args.num_workers > 1:
          screen.warning(
              "Playing the game as a human is only available with a single worker. "
              "The number of workers will be reduced to 1"
          )
          args.num_workers = 1
  
      args.framework = Frameworks[args.framework.lower()]
  
      # checkpoints
      args.checkpoint_save_dir = (
          os.path.join(args.experiment_path, "checkpoint")
          if args.checkpoint_save_secs is not None
          else None
      )
  
      if args.export_onnx_graph and not args.checkpoint_save_secs:
          screen.warning(
              "Exporting ONNX graphs requires setting the --checkpoint_save_secs flag. "
              "The --export_onnx_graph will have no effect."
          )
  
      if args.use_cpu or not CoachLauncher.gpus:
          CoachLauncher.gpus = [None]
  
      return args
  
imports: import sys
  import copy
  from configparser import ConfigParser, Error
  import os
  from rl_coach import logger
  import traceback
  from rl_coach.logger import screen, failed_imports
  import argparse
  import atexit
  import time
  import sys
  import json
  from rl_coach.base_parameters import Frameworks, VisualizationParameters, TaskParameters, DistributedTaskParameters, RunType, DistributedCoachSynchronizationType
  from rl_coach.core_types import TotalStepsCounter, RunPhase, PlayingStepsType, TrainingSteps, EnvironmentEpisodes, EnvironmentSteps, StepMethod, Transition
  from multiprocessing import Process
  from multiprocessing.managers import BaseManager
  import subprocess
  from glob import glob
  from rl_coach.graph_managers.graph_manager import HumanPlayScheduleParameters, GraphManager
  from rl_coach.utils import list_all_presets, short_dynamic_import, get_open_port, SharedMemoryScratchPad, get_base_dir, set_gpu
  from rl_coach.graph_managers.basic_rl_graph_manager import BasicRLGraphManager
  from rl_coach.environments.environment import SingleLevelSelection
  from rl_coach.memories.backend.redis import RedisPubSubMemoryBackendParameters
  from rl_coach.memories.backend.memory_impl import construct_memory_params
  from rl_coach.data_stores.data_store import DataStoreParameters
  from rl_coach.data_stores.s3_data_store import S3DataStoreParameters
  from rl_coach.data_stores.nfs_data_store import NFSDataStoreParameters
  from rl_coach.data_stores.redis_data_store import RedisDataStoreParameters
  from rl_coach.data_stores.data_store_impl import get_data_store, construct_data_store_params
  from rl_coach.training_worker import training_worker
  from rl_coach.rollout_worker import rollout_worker
  from rl_coach.schedules import *
  from rl_coach.exploration_policies.e_greedy import *
label_desc: Use image node_id 5 for calling the CoachLauncher obj's underlying member method code with example usage: obj.get_config_args(parser, arguments) and returns: args