Create the ``Config`` for a class by reflecting on its ``__init__``
    method and applying a few hacks.
161169
def _auto_config(cla55: Type[T]) -> Config[T]:
    
    typ3 = _get_config_type(cla55)

    # Don't include self, or vocab
    names_to_ignore = {"self", "vocab"}

    # Hack for RNNs
    if cla55 in [torch.nn.RNN, torch.nn.LSTM, torch.nn.GRU]:
        cla55 = torch.nn.RNNBase
        names_to_ignore.add("mode")

    if isinstance(cla55, type):
        # It's a class, so inspect its constructor
        function_to_inspect = cla55.__init__
    else:
        # It's a function, so inspect it, and ignore tensor
        function_to_inspect = cla55
        names_to_ignore.add("tensor")

    argspec = inspect.getfullargspec(function_to_inspect)
    comments = _docspec_comments(cla55)

    items: List[ConfigItem] = []

    num_args = len(argspec.args)
    defaults = list(argspec.defaults or [])
    num_default_args = len(defaults)
    num_non_default_args = num_args - num_default_args

    # Required args all come first, default args at the end.
    defaults = [_NO_DEFAULT for _ in range(num_non_default_args)] + defaults

    for name, default in zip(argspec.args, defaults):
        if name in names_to_ignore:
            continue
        annotation = argspec.annotations.get(name)
        comment = comments.get(name)

        # Don't include Model, the only place you'd specify that is top-level.
        if annotation == Model:
            continue

        # Don't include DataIterator, the only place you'd specify that is top-level.
        if annotation == DataIterator:
            continue

        # Don't include params for an Optimizer
        if torch.optim.Optimizer in getattr(cla55, '__bases__', ()) and name == "params":
            continue

        # Don't include datasets in the trainer
        if cla55 == Trainer and name.endswith("_dataset"):
            continue

        # Hack in our Optimizer class to the trainer
        if cla55 == Trainer and annotation == torch.optim.Optimizer:
            annotation = AllenNLPOptimizer

        # Hack in embedding num_embeddings as optional (it can be inferred from the pretrained file)
        if cla55 == Embedding and name == "num_embeddings":
            default = None

        items.append(ConfigItem(name, annotation, default, comment))

    # More hacks, Embedding
    if cla55 == Embedding:
        items.insert(1, ConfigItem("pretrained_file", str, None))

    return Config(items, typ3=typ3)
599269
def _initialize_honeybadger(self, config):
        
        if config.get('DEBUG', False):
            honeybadger.configure(environment='development')

        honeybadger_config = {}
        for key, value in iteritems(config):
            if key.startswith(self.CONFIG_PREFIX):
                honeybadger_config[key[len(self.CONFIG_PREFIX):].lower()] = value

        honeybadger.configure(**honeybadger_config)
        honeybadger.config.set_12factor_config()
522312
def init_config(app):
        """"""
        for k in dir(config):
            if k.startswith('CLASSIFIER_'):
                app.config.setdefault(k, getattr(config, k))
609824
def cond_init(m:nn.Module, init_func:LayerFunc):
    ""
    if (not isinstance(m, bn_types)) and requires_grad(m): init_default(m, init_func)
681728
def _init_attr_config(attr_cfg):
    """"""
    attr_cfg.name = ''
    attr_cfg.writable = AttrWriteType.READ
    attr_cfg.data_format = AttrDataFormat.SCALAR
    attr_cfg.data_type = 0
    attr_cfg.max_dim_x = 0
    attr_cfg.max_dim_y = 0
    attr_cfg.description = ''
    attr_cfg.label = ''
    attr_cfg.unit = ''
    attr_cfg.standard_unit = ''
    attr_cfg.display_unit = ''
    attr_cfg.format = ''
    attr_cfg.min_value = ''
    attr_cfg.max_value = ''
    attr_cfg.writable_attr_name = ''
    attr_cfg.extensions = []
273422
def init_params(self, initializer=mx.init.Uniform(0.01), **kwargs):
        
        self._module.init_params(initializer=initializer, **kwargs)
1203681
function(key, map, init) {
            this._configs = this._configs || {};
            map = map || {};
            if (!this._configs[key]) {
                map.name = key;
                this._configs[key] = this.createAttribute(map);
            } else {
                this._configs[key].configure(map, init);
            }
        }
986554
def _init_helper(self, vars_):
        """"""
        for k in vars_:
            if k == 'kwargs':
                for kwarg in vars_[k]:
                    setattr(self, kwarg, vars_[k][kwarg])
            elif k != 'self':
                setattr(self, k, vars_[k])
411935
def class_factory(name, base_class, class_dict):
    """"""

    def __init__(self, tcex):
        base_class.__init__(self, tcex)
        for k, v in class_dict.items():
            setattr(self, k, v)

    newclass = type(str(name), (base_class,), {'__init__': __init__})
    return newclass
1251298
function initConfig(conf) {
  const result = Object.assign({}, conf);
  if (conf.filename) {
    result.filepath = path.dirname(conf.filename);
  }
  return result;
}
1027421
def create_configwidget(self, parent):
        """"""
        if self.CONFIGWIDGET_CLASS is not None:
            configwidget = self.CONFIGWIDGET_CLASS(self, parent)
            configwidget.initialize()
            return configwidget
1039891
def init(self):
        
        # remove root logger, so we can reinit
        # TODO only remove our own
        # TODO move to _init, let overrides use init()
        logging.getLogger().handlers = []

        if self.debug:
            logging.basicConfig(level=logging.DEBUG, format=self.log_format_debug)
        elif self.verbose:
            logging.basicConfig(level=logging.INFO, format=self.log_format)
        elif not self.quiet:
            logging.basicConfig(level=logging.ERROR, format=self.log_format)
        else:
            logging.getLogger().addHandler(logging.NullHandler())
1180059
def check_initialized(method):
    """"""
    def _decorator(self, *args, **kwargs):
        if self._arguments is None or self._options is None:
            raise RuntimeError('using an uninitialized configuration')
        return method(self, *args, **kwargs)
    return _decorator
752969
def instantiate(self, cls=None):
        
        if cls is None:
            cls = self.cls
        if cls is None:
            raise TypeError("cls must a class")
        return cls.create(*self.args, **self.kwargs)
1073928
def new_instance(settings):
    
    settings = set_default({}, settings)
    if not settings["class"]:
        Log.error("Expecting 'class' attribute with fully qualified class name")

    # IMPORT MODULE FOR HANDLER
    path = settings["class"].split(".")
    class_name = path[-1]
    path = ".".join(path[:-1])
    constructor = None
    try:
        temp = __import__(path, globals(), locals(), [class_name], 0)
        constructor = object.__getattribute__(temp, class_name)
    except Exception as e:
        Log.error("Can not find class {{class}}", {"class": path}, cause=e)

    settings['class'] = None
    try:
        return constructor(kwargs=settings)  # MAYBE IT TAKES A KWARGS OBJECT
    except Exception as e:
        pass

    try:
        return constructor(**settings)
    except Exception as e:
        Log.error("Can not create instance of {{name}}", name=".".join(path), cause=e)
231404
def add_new_init_method(cls):
    

    orig_init = cls.__init__

    def new_init(self, *args, **kwargs):
        self._dependent_generators = []
        orig_init(self, *args, **kwargs)

    cls.__init__ = new_init
69801
def from_config(cls):
        """"""
        config = Config()
        client = cls(
            email=config.get('email'),
            api_key=config.get('api_key'),
            server=config.get('api_server'),
            http_proxy=config.get('http_proxy'),
            https_proxy=config.get('https_proxy'),
        )
        return client