code: def cast_structure(value, structure):
      """Cast a structure."""
      if tf.nest.is_nested(structure):
          if _is_namedtuple(
              structure
          ):  # pylint: disable=protected-access
              return type(structure)(*value)
          else:
              return type(structure)(value)
      return value
  
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: cast_structure(value, structure) and returns: value, type, type