code: def nest_constant(structure, value=1.0, dtype=None):
      """Constructs a nested structure similar to `structure` with constant values.
  
      Args:
        structure: A reference nested structure that is used for constant.
        value: Floating scalar setting the value of each entry of the structure.
          Default value: `1.0`.
        dtype: Optional dtype that specifies the dtype of the constant structure
          being produced. If `None`, then dtype is inferred from components of the
          structure.
          Default value: `None`.
  
      Returns:
        nest: Possibly nested structure of `Tensor`s with all entries equal to
        `value`. Has the same structure as `structure`.
      """
      flat_structure = tf.nest.flatten(structure)
      if dtype is None:
          dtypes = [c.dtype for c in flat_structure]
      else:
          dtypes = [dtype] * len(flat_structure)
      flat_vals = [
          tf.fill(ps.shape(c), tf.cast(value, dtype))
          for c, dtype in zip(flat_structure, dtypes)
      ]
      return tf.nest.pack_sequence_as(structure, flat_vals)
  
file_path: probability/tensorflow_probability/python/math/ode/runge_kutta_util.py
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 4 for calling a global function with example usage: nest_constant(structure, value, dtype) and returns: tf