# tff.structure.update_struct

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

Constructs a new `structure` with new values for fields in `kwargs`.

    tff.structure.update_struct(
        structure, **kwargs
    )

This is a helper method for working structured objects in a functional manner.
This method will create a new structure where the fields named by keys in
`kwargs` replaced with the associated values.

> [!NOTE]
> **Note:** _This method only works on the first level of `structure`, and does not recurse in the case of nested structures. A field that is itself a structure can be replaced with another structure.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `structure` | _The structure with named fields to update. |
| `**kwargs` | _The list of key-value pairs of fields to update in `structure`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A new instance of the same type of `structure`, with the fields named in the keys of `**kwargs` replaced with the associated values. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `KeyError` | If kwargs contains a field that is not in structure. |
| `TypeError` | If structure is not a structure with named fields. |

<br />