code: def validate_observation_data(
      kernel, observation_index_points, observations
  ):
      """Ensure that observation data and locations have consistent shapes.
  
      This basically means that the batch shapes are broadcastable. We can only
      ensure this when those shapes are fully statically defined.
  
  
      Args:
        kernel: The GP kernel.
        observation_index_points: the observation data locations in the index set.
        observations: the observation data.
  
      Raises:
        ValueError: if the observations' batch shapes are not broadcastable.
      """
      # Check that observation index points and observation counts broadcast.
      ndims = kernel.feature_ndims
  
      def _validate(t, nd):
          if nd > 0:
              shape = t.shape[:-nd]
          else:
              shape = t.shape
          if tensorshape_util.is_fully_defined(
              shape
          ) and tensorshape_util.is_fully_defined(observations.shape):
              index_point_count = shape
              observation_count = observations.shape
              try:
                  tf.broadcast_static_shape(
                      index_point_count, observation_count
                  )
              except ValueError:
                  # Re-raise with our own more contextual error message.
                  raise ValueError(  # pylint:disable=raise-missing-from
                      "Observation index point and observation counts are not "
                      "broadcastable: {} and {}, respectively.".format(
                          index_point_count, observation_count
                      )
                  )
  
      tf.nest.map_structure(_validate, observation_index_points, ndims)
  
file_path: probability/tensorflow_probability/python/distributions/internal/stochastic_process_util.py
imports: import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math.psd_kernels.internal import util
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: validate_observation_data(kernel, observation_index_points, observations) without return types