# tff.framework.transform_postorder

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Traverses `comp` recursively postorder and replaces its constituents.

    tff.framework.transform_postorder(
        comp, transform
    )

For each element of `comp` viewed as an expression tree, the transformation
`transform` is applied first to building blocks it is parameterized by, then
the element itself. The transformation `transform` should act as an identity
function on the kinds of elements (computation building blocks) it does not
care to transform. This corresponds to a post-order traversal of the
expression tree, i.e., parameters are always transformed left-to-right (in
the order in which they are listed in building block constructors), then the
parent is visited and transformed with the already-visited, and possibly
transformed arguments in place.

> [!NOTE]
> **Note:** In particular, in `Call(f,x)`, both `f` and `x` are arguments to `Call`. Therefore, `f` is transformed into `f'`, next `x` into `x'` and finally, `Call(f',x')` is transformed at the end.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `comp` | A `computation_building_block.ComputationBuildingBlock` to traverse and transform bottom-up. |
| `transform` | The transformation to apply locally to each building block in `comp`. It is a Python function that accepts a building block at input, and should return a (building block, bool) tuple as output, where the building block is a `computation_building_block.ComputationBuildingBlock` representing either the original building block or a transformed building block and the bool is a flag indicating if the building block was modified as. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The result of applying `transform` to parts of `comp` in a bottom-up fashion, along with a Boolean with the value `True` if `comp` was transformed and `False` if it was not. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the arguments are of the wrong computation_types. |
| `NotImplementedError` | If the argument is a kind of computation building block that is currently not recognized. |

<br />