def extract_valid_args(args, func, startidx=0):
    """
    Given a namespace of argparser args, extract those applicable to func.

    Arguments:
        args (Namespace): a namespace of args from argparse
        func (Function): a function to inspect, to determine valid args

    Returns:
        dict of (arg, value) pairs from args that are valid for func
    """
    func_args = inspect.getargspec(func).args[startidx:]
    return dict((k, v) for k, v in vars(args).items() if func_args in k)
dataset/ETHPy150Open NervanaSystems/neon/neon/util/argparser.py/extract_valid_args/swapped operands of `in`