Perform a sanity check on parameters passed in to CFG.__init__().
        An AngrCFGError is raised if any parameter fails the sanity check.

        :return: None
506010
def _sanitize_parameters(self):
        

        # Check additional_edges
        if isinstance(self._additional_edges, (list, set, tuple)):
            new_dict = defaultdict(list)
            for s, d in self._additional_edges:
                new_dict[s].append(d)
            self._additional_edges = new_dict

        elif isinstance(self._additional_edges, dict):
            pass

        else:
            raise AngrCFGError('Additional edges can only be a list, set, tuple, or a dict.')

        # Check _advanced_backward_slicing
        if self._advanced_backward_slicing and self._enable_symbolic_back_traversal:
            raise AngrCFGError('Advanced backward slicing and symbolic back traversal cannot both be enabled.')

        if self._advanced_backward_slicing and not self._keep_state:
            raise AngrCFGError('Keep state must be enabled if advanced backward slicing is enabled.')

        # Sanitize avoid_runs
        self._avoid_runs = [ ] if self._avoid_runs is None else self._avoid_runs
        if not isinstance(self._avoid_runs, (list, set)):
            raise AngrCFGError('"avoid_runs" must either be None, or a list or a set.')

        self._sanitize_starts()
1108379
def sg_init(sess):
     
    """
    # initialize variables
    sess.run(tf.group(tf.global_variables_initializer(),
                      tf.local_variables_initializer()))
634806
def annotated_cfg(self, start_point=None):
        

        # TODO: Support context-sensitivity

        targets = [ ]

        for simrun, stmt_idx in self._targets:
            targets.append((simrun.addr, stmt_idx))

        l.debug("Initializing AnnoCFG...")
        anno_cfg = AnnotatedCFG(self.project, self._cfg)

        for simrun, stmt_idx in self._targets:
            if stmt_idx is not -1:
                anno_cfg.set_last_statement(simrun.addr, stmt_idx)

        for n in self._cfg.graph.nodes():
            run = n

            if run.addr in self.chosen_statements:
                if self.chosen_statements[run.addr] is True:
                    anno_cfg.add_block_to_whitelist(run.addr)
                else:
                    anno_cfg.add_statements_to_whitelist(run.addr, self.chosen_statements[run.addr])

        for src, dst in self._cfg.graph.edges():
            run = src

            if dst.addr in self.chosen_statements and src.addr in self.chosen_statements:
                anno_cfg.add_exit_to_whitelist(run.addr, dst.addr)

        return anno_cfg
1241392
def init(parser = None):
    

    global p,subparsers
    if parser is None:
        p = argparse.ArgumentParser()
    else:
        p = parser

    arg = p.add_argument

    subparsers = p.add_subparsers()
570945
def init_params(net):
    """"""
    for module in net.modules():
        if isinstance(module, nn.Conv2d):
            init.kaiming_normal(module.weight, mode="fan_out")
            if module.bias:
                init.constant(module.bias, 0)
        elif isinstance(module, nn.BatchNorm2d):
            init.constant(module.weight, 1)
            init.constant(module.bias, 0)
        elif isinstance(module, nn.Linear):
            init.normal(module.weight, std=1e-3)
            if module.bias:
                init.constant(module.bias, 0)
772157
def _wrapinit(init):
    
    try:
        spec = getfullargspec(init)
    except TypeError:
        # we cannot preserve the type signature.
        def __init__(*args, **kwargs):
            self = args[0]
            __setattr__._initializing.add(self)
            init(*args, **kwargs)
            __setattr__._initializing.remove(self)
            _check_missing_slots(self)

        return __init__

    args = spec.args
    varargs = spec.varargs
    if not (args or varargs):
        raise TypeError(
            "%r must accept at least one positional argument for 'self'" %
            getattr(init, '__qualname__', getattr(init, '__name__', init)),
        )

    if not args:
        self = '%s[0]' % varargs
        forward = argspec = '*' + varargs
    else:
        self = args[0]
        forward = argspec = ', '.join(args)

    if args and varargs:
        forward = '%s, *%s' % (forward, spec.varargs)
        argspec = '%s, *%s' % (argspec, spec.varargs)
    if spec.kwonlyargs:
        forward = '%s, %s' % (
            forward,
            ', '.join(map('{0}={0}'.format, spec.kwonlyargs))
        )
        argspec = '%s,%s%s' % (
            argspec,
            '*, ' if not spec.varargs else '',
            ', '.join(spec.kwonlyargs),
        )
    if spec.varkw:
        forward = '%s, **%s' % (forward, spec.varkw)
        argspec = '%s, **%s' % (argspec, spec.varkw)

    ns = {
        '__init': init,
        '__initializing': __setattr__._initializing,
        '__check_missing_slots': _check_missing_slots,
    }
    exec(
        dedent(
            """\
            def __init__({argspec}):
                __initializing.add({self})
                __init({forward})
                __initializing.remove({self})
                __check_missing_slots({self})
            """.format(
                argspec=argspec,
                self=self,
                forward=forward,
            ),
        ),
        ns,
    )
    __init__ = ns['__init__']
    __init__.__defaults__ = spec.defaults
    __init__.__kwdefaults__ = spec.kwonlydefaults
    __init__.__annotations__ = spec.annotations
    return __init__
214681
def check_arguments(cls, conf):
        
        # Perform sanity checking on CIDR
        utils.ip_check(conf['fixed_cidr'], netmask_expected=True)

        # Perform sanity checking on host list
        for host in conf['fixed_hosts'].split(":"):
            utils.ip_check(host)
782137
def _check_errors(self):
        """"""
        # use this to make sure that sweep, sstart, sstop, and sinterval
        # all have values if one of them has values
        # (P^Q^R^S) OR (-P and -Q and -R and -S)
        # above is the minimal form for this logical statement in DNF
        if not ((self._inn(self.args.sweep) and self._inn(self.args.sstart)
                 and self._inn(self.args.sstop) and self._inn(self.args.sinterval))
                or
                (not self._inn(self.args.sweep) and not self._inn(self.args.sstart) and not
                 self._inn(self.args.sstop) and not self._inn(self.args.sinterval))):
            mutually_inclusive = ["sweep", "sstart", "sstop", "sinterval"]
            print_str = ""
            for each in mutually_inclusive:
                print_str += "    {0}: {1}\n".format(each, getattr(self.args, each))
            raise AssertionError("""You specified one or more of the --sweep,
            --sstart, --stop, or --sinterval arguments but did not specify all of
            them. All of them are required when running the program in sweep mode.
            Do not specify any of these arguments if not running the program in
            sweep mode.\n{0}""".format(print_str))
14973
def validate(cls, cfg, path="", nested=0, parent_cfg=None):
        

        # number of critical errors found
        num_crit = 0

        # number of non-critical errors found
        num_warn = 0


        # check for missing keys in the config
        for name in dir(cls):
            if nested > 0:
                break
            try:
                attr = getattr(cls, name)
                if isinstance(attr, Attribute):
                    if attr.default is None and name not in cfg:
                        # no default value defined, which means its required
                        # to be set in the config file
                        if path:
                            attr_full_name = "%s.%s" % (path, name)
                        else:
                            attr_full_name = name
                        raise vodka.exceptions.ConfigErrorMissing(
                            attr_full_name, attr)
                    attr.preload(cfg, name)

            except vodka.exceptions.ConfigErrorMissing as inst:
                if inst.level == "warn":
                    vodka.log.warn(inst.explanation)
                    num_warn += 1
                elif inst.level == "critical":
                    vodka.log.error(inst.explanation)
                    num_crit += 1


        if type(cfg) in [dict, Config]:
            keys = list(cfg.keys())
            if nested > 0:
                for _k, _v in cfg.items():
                    _num_crit, _num_warn = cls.validate(
                        _v,
                        path=("%s.%s" % (path, _k)),
                        nested=nested-1,
                        parent_cfg=cfg
                    )
                    num_crit += _num_crit
                    num_warn += _num_warn
                return num_crit, num_warn
        elif type(cfg) == list:
            keys = list(range(0, len(cfg)))
        else:
            raise ValueError("Cannot validate non-iterable config value")



        # validate existing keys in the config
        for key in keys:
            try:
                _num_crit, _num_warn = cls.check(cfg, key, path)
                num_crit += _num_crit
                num_warn += _num_warn
            except (
                vodka.exceptions.ConfigErrorUnknown,
                vodka.exceptions.ConfigErrorValue,
                vodka.exceptions.ConfigErrorType
            ) as inst:
                if inst.level == "warn":
                    vodka.log.warn(inst.explanation)
                    num_warn += 1
                elif inst.level == "critical":
                    vodka.log.error(inst.explanation)
                    num_crit += 1

        return num_crit, num_warn
1123274
def check_arguments(self):
        
        for k, v in self.Parameters.iteritems():
            if self.Parameters[k].isOn():
                if k in self._valid_arguments:
                    if not self._valid_arguments[k](v.Value):
                        error_message = 'Invalid argument (%s) ' % v.Value
                        error_message += 'for parameter %s\n' % k
                        raise InvalidArgumentApplicationError(error_message)
1358183
def _from_cfg(self, cfg):
        

        # Let's first add all functions first
        for func in cfg.kb.functions.values():
            self.add_function(func)

        self._mark_unknowns()
288690
def _initialize_cfg(self):
        

        self.kb.functions = FunctionManager(self.kb)

        self._jobs_to_analyze_per_function = defaultdict(set)
        self._completed_functions = set()
990746
def iter_def_argspec(self):
        
        started_kwargs = False
        seen_vars = set()

        for var, value in self.argpairs:
            if var is None:
                # value is actually the name
                var = value
                value = None

                if started_kwargs:
                    raise SyntaxError(
                        "Required argument %r must precede optional arguments"
                        % (var.name,))

            else:
                started_kwargs = True

            if not isinstance(var, Variable):
                raise SyntaxError("Expected variable name, got %r" % (var,))

            if var.name in seen_vars:
                raise SyntaxError("Duplicate argument %r" % (var.name,))
            seen_vars.add(var.name)

            yield var.name, value
1249406
def _make_args_checker(self):
        
        def _checker(*args, **kws):
            # Check if too many arguments are provided
            nargs = len(args)
            nnonvaargs = min(nargs, self._max_positional_args)
            if nargs > self._max_positional_args and self._ivararg is None:
                raise self._too_many_args_error(nargs)

            # Check if there are too few positional arguments (without defaults)
            if nargs < self._min_positional_args:
                missing = [p.name
                           for p in self.params[nargs:self._min_positional_args]
                           if p.name not in kws]
                # The "missing" arguments may still be provided as keywords, in
                # which case it's not an error at all.
                if missing:
                    raise self._too_few_args_error(missing, "positional")

            # Check if there are too few required keyword arguments
            if self._required_kwonly_args:
                missing = [kw
                           for kw in self._required_kwonly_args
                           if kw not in kws]
                if missing:
                    raise self._too_few_args_error(missing, "keyword")

            # Check types of positional arguments
            for i, argvalue in enumerate(args):
                param = self.params[i if i < self._max_positional_args else
                                    self._ivararg]
                if param.checker and not (
                    param.checker.check(argvalue) or
                    param.has_default and
                        (argvalue is param.default or argvalue == param.default)
                ):
                    raise self._param_type_error(param, param.name, argvalue)

            # Check types of keyword arguments
            for argname, argvalue in kws.items():
                argindex = self._iargs.get(argname)
                if argindex is not None and argindex < nnonvaargs:
                    raise self._repeating_arg_error(argname)
                index = self._iargs.get(argname)
                if index is None:
                    index = self._ivarkws
                if index is None:
                    s = "%s got an unexpected keyword argument `%s`" % \
                        (self.name_bt, argname)
                    raise self._type_error(s)
                param = self.params[index]
                if param.checker and not (
                    param.checker.check(argvalue) or
                    param.has_default and
                        (argvalue is param.default or argvalue == param.default)
                ):
                    raise self._param_type_error(param, argname, argvalue)

        return _checker
256851
def check_arguments(cls, conf):
        
        # Checking the specified list of basic health monitor plugins, which
        # should be run by the multi plugin.
        if not conf.get('multi_plugins'):
            raise ArgsError("A specification of health monitor plugins "
                            "is required (--multi_plugins).")

        # Now check parameters for all sub-plugins. We use the list of classes
        # for sub-plugins that we discovered earlier while adding parameters
        # for those sub-plugins.
        for mpc in cls.multi_plugin_classes:
            mpc.check_arguments(conf)
40991
def check_all_params_are_keyword(method):
    

    args, varargs, keywords, defaults = inspect.getargspec(method)

    # Always have self, thus the -1
    if len(args or []) - 1 != len(defaults or []):
        raise CooperativeError, "Init has positional parameters " + \
              str(args[1:])
    if varargs:
        raise CooperativeError, "Init has variadic positional parameters"
    if keywords:
        raise CooperativeError, "Init has variadic keyword parameters"
601865
def _initializer_wrapper(initializer, *args):
    
    signal.signal(signal.SIGINT, signal.SIG_IGN)
    if initializer is not None:
        initializer(*args)