returnn.util.collect_outputs_dict

Customized (derived) dict to pass as collected_outputs to some of the RF modules, or potential other use cases.

You can predefine (by pattern) what kind of outputs you want to collect and store in this dict.

class returnn.util.collect_outputs_dict.CollectOutputsDict(*args, allowed_key_patterns: Sequence[str] | None = None, **kwargs)[source]

Customized (derived) dict, where you can predefine (by key pattern) what kind of keys you want to collect and store in this dict. Other keys will be ignored.

Initialize the CollectOutputsDict.

Parameters:

allowed_key_patterns – List of key patterns (with wildcards) that are allowed to be stored in the dict. If None, all keys are allowed.

setdefault(key, default=None)[source]

Set default value for a key if it matches allowed patterns.

update(mapping, **kwargs)[source]

Update the dict with another mapping, only adding allowed keys.

is_key_allowed(key: str) bool[source]

Check if the key matches any of the allowed patterns.

Parameters:

key

Returns:

True if the key is allowed, False otherwise.

returnn.util.collect_outputs_dict.is_key_allowed_in_collect_outputs_dict(collect_outputs: CollectOutputsDict | dict, key: str) bool[source]

Check if a key is allowed in the given CollectOutputsDict.

Parameters:
  • collect_outputs

  • key

Returns:

True if the key is allowed, False otherwise.