DefaultDict Class

class model_compression_toolkit.DefaultDict(known_dict=None, default_value=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 value (that is passed at initialization) generates.

Parameters:
  • known_dict – Dictionary to wrap. If None is provided, initializes an empty dictionary.

  • default_value – default value 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 – 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

keys()

Get keys of known_dict Returns: keys of known_dict