Constructs a structure from a type_spec tree of tff.TensorTypes.

fn A callable used to generate the elements with which to fill the resulting structure. fn will be called exactly once per leaf tff.TensorType in the order they appear in the type_spec structure.
type_spec A TFF type or value convertible to TFF type. Once converted, type_spec must be a tff.TensorType or tff.StructType containing only other tff.TensorTypes and tff.StructTypes.

A structure with the same shape and Python containers as type_spec but with the tff.TensorType elements replaced with the results of fn.

ValueError if the provided type_spec is not a structural or tensor type.