# tff.structure.map_structure

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

Applies `fn` to each entry in `structure` and returns a new structure.

    tff.structure.map_structure(
        fn: Callable[..., object], *structures
    ) -> object

This is a special implementation of [`tf.nest.map_structure`](https://www.tensorflow.org/api_docs/python/tf/nest/map_structure)
that works for `Struct`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `fn` | a callable that accepts as many arguments as there are structures. |
| `*structures` | a scalar, tuple, or list of constructed scalars and/or tuples/lists, or scalars. Note: numpy arrays are considered scalars. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A new structure with the same arity as `structure` and same type as `structure[0]`, whose values correspond to `fn(x[0], x[1], ...)` where `x[i]` is a value in the corresponding location in `structure[i]`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | if `fn` is not a callable, or \*structure is not all `Struct` or all [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) typed values. |
| `ValueError` | if `*structure` is empty. |

<br />