tff.utils.identity

Applies tf.identity pointwise to source.

This utility function provides the exact same behavior as tf.identity, but it generalizes to a wider class of objects, including ordinary tensors, variables, as well as various types of nested structures. It would typically be used together with tf.control_dependencies in non-eager TensorFlow.

source A nested structure composed of tensors or variables embedded in containers that are compatible with tf.nest, or instances of structure.Struct. Elements that represent variables have their content extracted prior to identity mapping by first invoking tf.Variable.read_value.

The result of applying tf.identity to read all elements of the source pointwise, with the same structure as source.

TypeError If types mismatch.