code: def parse_arguments(cfg):
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "-datadir",
          "--datadir",
          help="Data directory where the ImageNet dataset is located",
          required=False,
          default=cfg["DATA"].MAP_FILE_PATH,
      )
      parser.add_argument(
          "-outputdir",
          "--outputdir",
          help="Output directory for checkpoints and models",
          required=False,
          default=None,
      )
      parser.add_argument(
          "-logdir",
          "--logdir",
          help="Log file",
          required=False,
          default=None,
      )
      parser.add_argument(
          "-n",
          "--num_epochs",
          help="Total number of epochs to train",
          type=int,
          required=False,
          default=cfg["CNTK"].MAX_EPOCHS,
      )
      parser.add_argument(
          "-m",
          "--minibatch_size",
          help="Minibatch size",
          type=int,
          required=False,
          default=cfg.MB_SIZE,
      )
      parser.add_argument(
          "-e",
          "--epoch_size",
          help="Epoch size",
          type=int,
          required=False,
          default=cfg["DATA"].NUM_TRAIN_IMAGES,
      )
      parser.add_argument(
          "-q",
          "--quantized_bits",
          help="Number of quantized bits used for gradient aggregation",
          type=int,
          required=False,
          default="32",
      )
      parser.add_argument(
          "-r",
          "--restart",
          help="Indicating whether to restart from scratch (instead of restart from checkpoint file by default)",
          action="store_true",
      )
      parser.add_argument(
          "-device",
          "--device",
          type=int,
          help="Force to run the script on a specified device",
          required=False,
          default=None,
      )
      parser.add_argument(
          "-lrFactor",
          "--lrFactor",
          type=float,
          help="Scale factor for the lr schedule",
          required=False,
      )
      parser.add_argument(
          "-momentumPerMb",
          "--momentumPerMb",
          type=float,
          help="momentum per minibatch",
          required=False,
      )
      parser.add_argument(
          "-rndSeed",
          "--rndSeed",
          type=int,
          help="the random seed",
          required=False,
      )
      parser.add_argument(
          "-trainConv",
          "--trainConv",
          type=int,
          help="whether to train conv layers",
          required=False,
      )
  
      args = vars(parser.parse_args())
  
      if args["lrFactor"] is not None:
          cfg["CNTK"].LR_FACTOR = args["lrrFactor"]
      if args["num_epochs"] is not None:
          cfg["CNTK"].MAX_EPOCHS = args["num_epochs"]
      if args["momentumPerMb"] is not None:
          cfg.MOMENTUM_PER_MB = args["momentumPerMb"]
      if args["rndSeed"] is not None:
          cfg.RND_SEED = args["rndSeed"]
      if args["trainConv"] is not None:
          cfg["CNTK"].TRAIN_CONV_LAYERS = (
              True if args["trainConv"] == 1 else False
          )
  
      if args["datadir"] is not None:
          cfg["DATA"].MAP_FILE_PATH = args["datadir"]
      if args["outputdir"] is not None:
          cfg.OUTPUT_PATH = args["outputdir"]
      if args["logdir"] is not None:
          log_dir = args["logdir"]
      if args["device"] is not None:
          # Setting one worker on GPU and one worker on CPU. Otherwise memory consumption is too high for a single GPU.
          if Communicator.rank() == 0:
              cntk.device.try_set_default_device(
                  cntk.device.gpu(args["device"])
              )
          else:
              cntk.device.try_set_default_device(cntk.device.cpu())
  
imports: from __future__ import print_function
  import numpy
  import os, sys
  import argparse
  import easydict
  import cntk
  from cntk import Trainer, load_model, Axis, input_variable, parameter, times, combine, softmax, roipooling, plus, element_times, CloneMethod, alias, Communicator, reduce_sum
  from cntk.core import Value
  from cntk.initializer import normal
  from cntk.layers import placeholder, Constant, Sequential
  from cntk.learners import momentum_sgd, learning_parameter_schedule_per_sample, momentum_schedule
  from cntk.logging import log_number_of_parameters, ProgressPrinter
  from cntk.logging.graph import find_by_name, plot
  from cntk.losses import cross_entropy_with_softmax
  from cntk.metrics import classification_error
  from _cntk_py import force_deterministic_algorithms
  from utils.rpn.cntk_smoothL1_loss import SmoothL1Loss
  from utils.annotations.annotations_helper import parse_class_map_file
  from utils.od_mb_source import ObjectDetectionMinibatchSource
  from utils.proposal_helpers import ProposalProvider
label_desc: Use image node_id 2 for calling a global function with example usage: parse_arguments(cfg) without return types