# tff.aggregators.add_measurements

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

Wraps `AggregationFactory` to report additional measurements.

    tff.aggregators.add_measurements(
        inner_agg_factory: https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/AggregationFactory,
        *,
        client_measurement_fn: Optional[Callable[..., dict[str, Any]]] = None,
        server_measurement_fn: Optional[Callable[..., dict[str, Any]]] = None
    ) -> https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/AggregationFactory

The function `client_measurement_fn` should be a Python callable that will be
called as `client_measurement_fn(value)` or `client_measurement_fn(value,
weight)` depending on whether `inner_agg_factory` is weighted or unweighted.
It must be traceable by TFF and expect [`tff.Value`](https://www.tensorflow.org/federated/api_docs/python/tff/Value) objects placed at `CLIENTS`
as inputs, and return a `collections.OrderedDict` mapping string names to
tensor values placed at `SERVER`, which will be added to the measurement dict
produced by the `inner_agg_factory`.

Similarly, `server_measurement_fn` should be a Python callable that will be
called as `server_measurement_fn(result)` where `result` is the result (on
server) of the inner aggregation.

One or both of `client_measurement_fn` and `server_measurement_fn` must be
specified.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `inner_agg_factory` | The factory to wrap and add measurements. |
| `client_measurement_fn` | A Python callable that will be called on `value` (and/or `weight`) provided to the `next` function to compute additional measurements of the client values/weights. |
| `server_measurement_fn` | A Python callable that will be called on the `result` of aggregation at server to compute additional measurements of the result. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An `AggregationFactory` that reports additional measurements. ||

<br />