tfp.experimental.unnest.replace_outermost

Replace (nested) fields in a namedtuple.

For each attribute-value update specified, this function only replaces the first matching attribute found. Nested objects are traversed breadth-first, with level-wise order determined by the list ordering returned from nested_lookup_fn.

ntuple A namedtuple to replace (nested) fields in.
return_unused If True, return the dict of attribute-value pairs in **kw that were not found and updated in ntuple.
nested_lookup_fn A single-argument callable that returns a list of (attribute name, nested object) pairs. Defaults to get_nested_objs.
**kw The attribute-value pairs to update.

updated A copy of ntuple with (nested) fields updated.
unused If return_unused is True, the dictionary of attribute-value pairs in **kw that were not found and updated in ntuple.

ValueError if returne_unused=False and attributes in **kw are not found in ntuple.