:type default_args_sample list
    :rtype dict
357575
def parse_default_arguments(self, default_args_sample):
    
    parsed_arguments_dict = {}
    default_arguments = list(self._arguments.default_arguments.values())
    expected_length = len(default_arguments)
    real_length = len(default_args_sample)

    default_args_count = len([item for item in default_arguments if item.default is not None])

    if not self._arguments.has_optional_default_argument and (default_args_sample is None or expected_length != real_length):
      raise ArgumentException("Command require {} positional argument(s), found {}".format(
        expected_length,
        real_length
      ))
    elif self._arguments.has_optional_default_argument and default_args_sample is not None and real_length < expected_length - default_args_count:
      raise ArgumentException("Command require {} or {} positional argument(s), found {}".format(
        expected_length,
        expected_length - default_args_count,
        real_length
      ))

    for index in range(0, expected_length):
      arg_meta = default_arguments[index]
      """:type arg_meta ModuleArgumentItem"""
      try:
        arg = default_args_sample[index]
      except IndexError:
        arg = arg_meta.default

      try:
        if arg_meta.value_type is not None:
          arg = self.__convert_value_to_type(arg, arg_meta.value_type)

        parsed_arguments_dict[arg_meta.name] = arg
      except (TypeError, ValueError):
        raise ArgumentException("Invalid argument type - expected {}, got {}".format(arg_meta.value_type.__name__, type(arg).__name__))

    return parsed_arguments_dict
353466
def _build_instance_group_list_args(self, instance_groups):
        
        if type(instance_groups) != types.ListType:
            instance_groups = [instance_groups]

        params = {}
        for i, instance_group in enumerate(instance_groups):
            ig_dict = self._build_instance_group_args(instance_group)
            for key, value in ig_dict.iteritems():
                params['InstanceGroups.member.%d.%s' % (i+1, key)] = value
        return params
380767
def load_cli_args(self):
        
        parser = argparse.ArgumentParser(description='QTPyLib Reporting',
                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)

        parser.add_argument('--port', default=self.args["port"],
                            help='HTTP port to use', type=int)
        parser.add_argument('--host', default=self.args["host"],
                            help='Host to bind the http process to')
        parser.add_argument('--blotter',
                            help='Use this Blotter\'s MySQL server settings')
        parser.add_argument('--nopass',
                            help='Skip password for web app (flag)',
                            action='store_true')

        # only return non-default cmd line args
        # (meaning only those actually given)
        cmd_args, _ = parser.parse_known_args()
        args = {arg: val for arg, val in vars(
            cmd_args).items() if val != parser.get_default(arg)}
        return args
689780
def describe_arguments(func):
    

    argspec = inspect.getargspec(func)
    # we should probably raise an exception somewhere if func includes **kwargs
    if argspec.defaults:
        positional_args = argspec.args[:-len(argspec.defaults)]
        keyword_names = argspec.args[-len(argspec.defaults):]
        for arg, default in zip(keyword_names, argspec.defaults):
            yield ('--{}'.format(arg),), {'default': default}
    else:
        positional_args = argspec.args

    for arg in positional_args:
        yield (arg,), {}
    if argspec.varargs:
        yield (argspec.varargs,), {'nargs': '*'}
164901
def get_native_default_args():
    
    native_default_args = dict(max_jobs=500,
                               time_per_cycle=15,
                               jobs_per_cycle=20,
                               max_job_age=90,
                               no_batch=False)
    return native_default_args.copy()
473379
def default_settings(params):
    
    def _default_settings(fn, command):
        for k, w in params.items():
            settings.setdefault(k, w)
        return fn(command)
    return decorator(_default_settings)
182898
def default_args(self):
        """"""
        if self._default_args is None:
            self._default_args, unknown = self.parser.parse_known_args()  # pylint: disable=W0612
            # reinitialize logger with new log level and api settings
            self.tcex._logger()
            if self._default_args.tc_aot_enabled:
                # block for AOT message and get params
                params = self.tcex.playbook.aot_blpop()
                self.inject_params(params)
            elif self._default_args.tc_secure_params:
                # inject secure params from API
                params = self._load_secure_params()
                self.inject_params(params)
        return self._default_args
719411
def apply_dict_default(dictionary, arg, default):
    '''
    
    '''
    if arg not in dictionary:
        if hasattr(default, '__call__'):
            # Don't try/catch because the method could raise a TypeError and we'd hide it
            default = restrict_args(default, arg)
        dictionary[arg] = default
    return dictionary
1195343
def list_from_args(args):
    
    # Empty args
    if not args:
        return []

    # Get argument type
    arg_type = type(args[0])
    is_list = arg_type in LIST_TYPES

    # Check that the arguments are uniforn (of same type)
    same_type = all([
        isinstance(arg, arg_type)
        for arg in args
    ])

    if not same_type:
        raise Exception('Expected uniform arguments of same type !')

    # Flatten iterables
    # ['x', 'y'], ...
    if is_list:
        args_lists = map(list, args)
        flattened_args = sum(args_lists, [])
        return flattened_args
    # Flatten set
    # 'x', 'y'
    return list(args)
291993
def args(self):  # as args tuple
        '''
        '''
        return (self.base, self.item, self.leng, self.refs,
                self.both, self.kind, self.type)
1136031
def _get_default_field_kwargs(model, field):
        
        kwargs = {}
        try:
            field_name = field.model_attr or field.index_fieldname
            model_field = model._meta.get_field(field_name)
            kwargs.update(get_field_kwargs(field_name, model_field))

            # Remove stuff we don't care about!
            delete_attrs = [
                "allow_blank",
                "choices",
                "model_field",
                "allow_unicode",
            ]
            for attr in delete_attrs:
                if attr in kwargs:
                    del kwargs[attr]
        except FieldDoesNotExist:
            pass

        return kwargs
590135
def _construct_context_for_args(args):
  
  global_default_context = google.datalab.Context.default()
  config = {}
  for key in global_default_context.config:
    config[key] = global_default_context.config[key]

  billing_tier_arg = args.get('billing', None)
  if billing_tier_arg:
    config['bigquery_billing_tier'] = billing_tier_arg

  return google.datalab.Context(
    project_id=global_default_context.project_id,
    credentials=global_default_context.credentials,
    config=config)
801920
def parse_args():
    
    parser = argparse.ArgumentParser()
    parser.add_argument('--gpu-id', type=int, default=0,
                        help='GPU id (-1 means CPU)')
    parser.add_argument('--train-file', default='snli_1.0/snli_1.0_train.txt',
                        help='training set file')
    parser.add_argument('--test-file', default='snli_1.0/snli_1.0_dev.txt',
                        help='validation set file')
    parser.add_argument('--max-num-examples', type=int, default=-1,
                        help='maximum number of examples to load (for debugging)')
    parser.add_argument('--batch-size', type=int, default=32,
                        help='batch size')
    parser.add_argument('--print-interval', type=int, default=20,
                        help='the interval of two print')
    parser.add_argument('--mode', choices=['train', 'test'], default='train',
                        help='train or test')
    parser.add_argument('--lr', type=float, default=0.025,
                        help='learning rate')
    parser.add_argument('--epochs', type=int, default=300,
                        help='maximum number of epochs to train')
    parser.add_argument('--embedding', default='glove',
                        help='word embedding type')
    parser.add_argument('--embedding-source', default='glove.840B.300d',
                        help='embedding file source')
    parser.add_argument('--embedding-size', type=int, default=300,
                        help='size of pretrained word embedding')
    parser.add_argument('--hidden-size', type=int, default=200,
                        help='hidden layer size')
    parser.add_argument('--output-dir', default='./output',
                        help='directory for all experiment output')
    parser.add_argument('--model-dir', default='./output',
                        help='directory to load model')
    parser.add_argument('--seed', type=int, default=0,
                        help='random seed')
    parser.add_argument('--dropout', type=float, default=0.,
                        help='dropout rate')
    parser.add_argument('--weight-decay', type=float, default=0.,
                        help='l2 regularization weight')
    parser.add_argument('--intra-attention', action='store_true',
                        help='use intra-sentence attention')

    return parser.parse_args()
490608
def get_args_kwargs(foo):
    
    spec = inspect.signature(foo)
    params = spec.parameters
    args,args_with_def=[],[]
    for n,p in params.items():
        if p.default is p.empty:
            args.append(n)
        else:
            args_with_def.append(n)
    return args,args_with_def
629349
def instance_for_arguments(self, arguments):
        
        result = ModelInstance()
        for key, value in self.__dict__.items():
            if isinstance(value, AbstractPriorModel):
                value = value.instance_for_arguments(arguments)
            setattr(result, key, value)
        return result
488714
def get_argument_values(
    arg_defs,  # type: Union[Dict[str, GraphQLArgument], Dict]
    arg_asts,  # type: Optional[List[Argument]]
    variables=None,  # type: Optional[Dict[str, Union[List, Dict, int, float, bool, str, None]]]
):
    # type: (...) -> Dict[str, Any]
    """"""
    if not arg_defs:
        return {}

    if arg_asts:
        arg_ast_map = {
            arg.name.value: arg for arg in arg_asts
        }  # type: Dict[str, Argument]
    else:
        arg_ast_map = {}

    result = {}
    for name, arg_def in arg_defs.items():
        arg_type = arg_def.type
        arg_ast = arg_ast_map.get(name)
        if name not in arg_ast_map:
            if arg_def.default_value is not None:
                result[arg_def.out_name or name] = arg_def.default_value
                continue
            elif isinstance(arg_type, GraphQLNonNull):
                raise GraphQLError(
                    'Argument "{name}" of required type {arg_type}" was not provided.'.format(
                        name=name, arg_type=arg_type
                    ),
                    arg_asts,
                )
        elif isinstance(arg_ast.value, ast.Variable):  # type: ignore
            variable_name = arg_ast.value.name.value  # type: ignore
            if variables and variable_name in variables:
                result[arg_def.out_name or name] = variables[variable_name]
            elif arg_def.default_value is not None:
                result[arg_def.out_name or name] = arg_def.default_value
            elif isinstance(arg_type, GraphQLNonNull):
                raise GraphQLError(
                    'Argument "{name}" of required type {arg_type}" provided the variable "${variable_name}" which was not provided'.format(
                        name=name, arg_type=arg_type, variable_name=variable_name
                    ),
                    arg_asts,
                )
            continue

        else:
            value = value_from_ast(arg_ast.value, arg_type, variables)  # type: ignore
            if value is None:
                if arg_def.default_value is not None:
                    value = arg_def.default_value
                    result[arg_def.out_name or name] = value
            else:
                # We use out_name as the output name for the
                # dict if exists
                result[arg_def.out_name or name] = value

    return result
1015436
def consume_arguments(self, argument_list):
        
        if len(argument_list) == 0:
            return []
        if argument_list[0] == self.arg_name:
            argument_list = argument_list[1:]
            if self.constraint is bool:
                self.value = not self.value
            else:
                try:
                    value = argument_list.pop(0)
                except IndexError:
                    raise ParameterError('Argument %s expects a value' % self.arg_name)
                self.value = value
        return argument_list