# tff.templates.chain_measured_processes

<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) |

Creates a composition of multiple [`tff.templates.MeasuredProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/MeasuredProcess)es.

    tff.templates.chain_measured_processes(
        measured_processes: collections.OrderedDict[str, MeasuredProcess]
    ) -> https://www.tensorflow.org/federated/api_docs/python/tff/templates/MeasuredProcess

Composing `MeasuredProcess`es is a chaining process in which the output of the
first `MeasuredProcess` feeds the input of the following `MeasuredProcess`.
For example, given `y = f(x)` and `z = g(y)`, this produces a new `z = h(x)`
such that `h(x) = g(f(x))`.

*Guidance for Composition*
Two `MeasuredProcess`es *F(x)* and *G(y)* can be composed into a new
`MeasuredProcess` called *C* with the following properties:

- `C.state` is the concatenation `<F=F.state, G=G.state>` as an `OrderedDict`.
- `C.next(C.state, x).result ==
  G.next(G.state, F.next(F.state, x).result).result`
- `C.measurements` is the concatenation `<F=F.measurements, G=G.measurements>` as an `OrderedDict`.

The resulting composition *C* would have the following type signatures:
initialize: `( -> <F=F.initialize, G=G.initialize>)`
next: `(<<F=F.state, G=G.state>, F.input> -> <state=<F=F.state, G=G.State>,
result=G.result, measurements=<F=F.measurements, G=G.measurements>)`

Note that the guidance for composition is not strict and details are allowed
to differ.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `measured_processes` | An `OrderedDict` of `MeasuredProcess`es with keys as the process name and values as the corresponding `MeasuredProcess`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `MeasuredProcess` of the composition of input `MeasuredProcess`es. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the `MeasuredProcess`es have the state at different placement (e.g. F.state@SERVER, G.state@CLIENTS). |
| `TypeError` | If the function argment type doesn't match with the input type of the composite function. |

<br />