core.replace_leaves
core.replace_leaves(tree, old, new)Swap leaves of a pytree by identity.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| tree | P | A posterior, or any pytree. | required |
| old | tuple[Tensor, …] | Leaves of tree to replace. |
required |
| new | tuple[Tensor, …] | Their replacements, in the same order. | required |
Returns
| Name | Type | Description |
|---|---|---|
| P | The tree with each leaf that is old[i] replaced by new[i]. |