# tf.contrib.framework.nest.map_structure_with_paths

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/util/nest.py#L540-L579) |

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

    tf.contrib.framework.nest.map_structure_with_paths(
        func, *structure, **kwargs
    )

Applies `func(path, x[0], x[1], ..., **kwargs)` where x\[i\] is an entry in
`structure[i]` and `path` is the common path to x\[i\] in the structures. All
structures in `structure` must have the same arity, and the return value will
contain the results with the same structure layout. Special kwarg
`check_types` determines whether the types of iterables within the structure
must be the same-- see \*\*kwargs definition below.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `func` | A callable with the signature func(path, \*values, \*\*kwargs) that is evaluated on the leaves of the structure. |
| `*structure` | A variable number of compatible structures to process. |
| `**kwargs` | Optional kwargs to be passed through to func. Special kwarg `check_types` is not passed to func, but instead determines whether the types of iterables within the structures have to be same (e.g., `map_structure(func, [1], (1,))` raises a `TypeError` exception). By default, the types must match. To allow iteration over structures of different types (but common arity), set this kwarg to `False`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A structure of the same form as the input structures whose leaves are the result of evaluating func on corresponding leaves of the input structures. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `func` is not callable or if the structures do not match each other by depth tree. |
| `TypeError` | If `check_types` is not `False` and the two structures differ in the type of sequence in any of their substructures. |
| `ValueError` | If no structures are provided. |

<br />