DefaultDict Class¶
- class model_compression_toolkit.DefaultDict(known_dict, default_factory=None)¶
Default dictionary. It wraps a dictionary given at initialization and return its values when requested. If the requested key is not presented at initial dictionary, it returns the returned value a default factory (that is passed at initialization) generates.
- Parameters
known_dict (Dict[Any, Any]) – Dictionary to wrap.
default_factory (Callable) – Callable to get default values when requested key is not in known_dict.
- get(key)¶
Get the value of the inner dictionary by the given key, If key is not in dictionary, it uses the default_factory to return a default value.
- Parameters
key (Any) – Key to use in inner dictionary.
- Returns
Value of the inner dictionary by the given key, or a default value if not exist. If default_factory was not passed at initialization, it returns None.
- Return type
Any