'Parse the command line arguments and setup neon
runtime environment accordingly
Arguments:
gen_be (bool): if False, the arg parser will not
generate the backend
Returns:
namespace: contains the parsed arguments as attributes'

def parse_args(self, gen_be=True):

    args = super(NeonArgparser, self).parse_args()
    err_msg = None
    try:
        log_thresh = max(10, (40 - (args.verbose * 10)))
    except (AttributeError, TypeError):
        log_thresh = 30
    args.log_thresh = log_thresh
    fmtr = logging.Formatter('%(asctime)s    -    %(name)s    -    %(levelname)s    -    %(message)s')
    main_logger = logging.getLogger('neon')
    main_logger.setLevel(log_thresh)
    stderrlog = logging.StreamHandler()
    stderrlog.setFormatter(fmtr)
    for path in ['data_dir', 'save_path', 'model_file', 'output_file', 'logfile']:
        if getattr(args, path):
            setattr(args, path, os.path.expanduser(getattr(args, path)))
    if args.logfile:
        filelog = RotatingFileHandler(filename=args.logfile, mode='w', maxBytes=10000000, backupCount=5)
        filelog.setFormatter(fmtr)
        filelog.setLevel(log_thresh)
        main_logger.addHandler(filelog)
        if args.no_progress_bar:
            stderrlog.setLevel(log_thresh)
        else:
            stderrlog.setLevel(logging.ERROR)
    else:
        stderrlog.setLevel(log_thresh)
    main_logger.propagate = False
    main_logger.addHandler(stderrlog)
    args.datatype = ('float' + args.datatype[1:])
    args.datatype = np.dtype(args.datatype).type
    args.progress_bar = (not args.no_progress_bar)
    if ((args.backend == 'cpu') and (args.rounding > 0)):
        err_msg = 'CPU    backend    does    not    support    stochastic    rounding'
        logger.exception(err_msg)
        raise NotImplementedError(err_msg)
    if args.save_path:
        savedir = os.path.dirname(os.path.abspath(args.save_path))
        if (not os.access(savedir, (os.R_OK | os.W_OK))):
            try:
                os.makedirs(savedir)
            except OSError:
                err_msg = ('Can    not    create    save_path    %s' % savedir)
        if os.path.exists(args.save_path):
            logger.warning(('save    file    %s    exists,    attempting    to    overwrite' % args.save_path))
            if (not os.access(args.save_path, (os.R_OK | os.W_OK))):
                err_msg = ('Can    not    write    to    save_path    file    %s' % args.save_path)
        if err_msg:
            logger.exception(err_msg)
            raise IOError(err_msg)
    if ((args.serialize > 0) and (args.save_path is None)):
        args.save_path = 'neon_model.pkl'
        logger.warn('No    path    given    for    model    serialization,    using    default    "%s"', args.save_path)
    if ((args.save_path is not None) and (args.serialize == 0)):
        args.serialize = 1
        logger.warn('No    schedule    given    for    model    serialization,    using    default    %d', args.serialize)
    if args.model_file:
        err_msg = None
        if (not os.path.exists(args.model_file)):
            err_msg = ('Model    file    %s    not    present' % args.model_file)
        if (not os.access(args.model_file, os.R_OK)):
            err_msg = ('No    read    access    for    model    file    %s' % args.model_file)
        if err_msg:
            logger.exception(err_msg)
            raise IOError(err_msg)
    if args.caffe:
        args.compat_mode = 'caffe'
    else:
        args.compat_mode = None
    if args.deterministic:
        logger.warn('--deterministic    flag    is    deprecated.        Specify    random    seed    for    deterministic    behavior.')
    if gen_be:
        gen_backend(backend=args.backend, rng_seed=args.rng_seed, device_id=args.device_id, batch_size=args.batch_size, datatype=args.datatype, max_devices=args.max_devices, compat_mode=args.compat_mode)
    logger.info(self.format_values())
    if args.manifest:
        args.manifest = {k: v for (k, v) in [ss.split(':') for ss in args.manifest]}
    self._PARSED = True
    self.args = args
    args.callback_args = extract_valid_args(args, Callbacks.__init__, startidx=1)
    return args
