@classmethod
def from_config_dict(cls, config_dict, **extra_kwargs):
    """
        Convert a dictionary, checking for invalid keys, that can be
        safely passed as kwargs. Checks only for the presence of options
        (keys), not their types. Converts dashes to underscores in
        option names.

        Considers optional arguments to cls.__init__() optional options,
        and required arguments to cls.__init__() required options.
        Rejects options also found in extra_kwargs.
        """
    if isinstance(config_dict, cls):
        return config_dict
    required_args, optional_args = cls._find_args(extra_kwargs)
    kwargs = {}
    for raw_key in config_dict:
        key = cls._to_field(raw_key)
        if key not in required_args + optional_args:
            raise ValueError("Unknown config key `{}'".format(raw_key))
        kwargs[key] = config_dict[raw_key]
    for key in required_args:
        if key not in kwargs:
            raw_key = cls._to_config(key)
            raise ValueError("Missing required config key `{}'".format(raw_key)
                )
    kwargs.update(extra_kwargs)
    return cls(**kwargs)
