code: def testLateBindingIndexPoints(self):
      amp = np.float64(0.5)
      len_scale = np.float64(0.2)
      kernel = psd_kernels.ExponentiatedQuadratic(amp, len_scale)
      mean_fn = lambda x: x[..., 0] ** 2
      jitter = np.float64(1e-4)
      observation_noise_variance = np.float64(3e-3)
  
      gp = gaussian_process.GaussianProcess(
          kernel=kernel,
          mean_fn=mean_fn,
          observation_noise_variance=observation_noise_variance,
          jitter=jitter,
          validate_args=True,
      )
  
      index_points = np.random.uniform(-1.0, 1.0, [5, 10, 1])
  
      # Check that the internal batch_shape and event_shape methods work.
      self.assertAllEqual(
          [5], gp._batch_shape(index_points=index_points)
      )  # pylint: disable=protected-access
      self.assertAllEqual(
          [10], gp._event_shape(index_points=index_points)
      )  # pylint: disable=protected-access
  
      expected_mean = mean_fn(index_points)
      self.assertAllClose(
          expected_mean,
          self.evaluate(gp.mean(index_points=index_points)),
      )
  
      # Check that late-binding samples work.
      self.evaluate(
          gp.sample(
              seed=test_util.test_seed(), index_points=index_points
          )
      )
  
      def _kernel_fn(x, y):
          return amp**2 * np.exp(
              -0.5 * (np.squeeze((x - y) ** 2)) / (len_scale**2)
          )
  
      expected_covariance = _kernel_fn(
          np.expand_dims(index_points, -3),
          np.expand_dims(index_points, -2),
      ) + observation_noise_variance * np.eye(10)
  
      self.assertAllClose(
          expected_covariance,
          self.evaluate(gp.covariance(index_points=index_points)),
      )
      self.assertAllClose(
          np.diagonal(expected_covariance, axis1=-2, axis2=-1),
          self.evaluate(gp.variance(index_points=index_points)),
      )
      self.assertAllClose(
          np.sqrt(np.diagonal(expected_covariance, axis1=-2, axis2=-1)),
          self.evaluate(gp.stddev(index_points=index_points)),
      )
  
      # Calling mean with no index_points should raise an Error
      with self.assertRaises(ValueError):
          gp.mean()
  
      # Calling sample with no index_points should raise an Error
      with self.assertRaises(ValueError):
          gp.sample(seed=test_util.test_seed())
  
      self.assertIn("event_shape=?", repr(gp))
      self.assertIn(
          "event_shape=[10]", repr(gp.copy(index_points=index_points))
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import gaussian_process
  from tensorflow_probability.python.distributions import gaussian_process_regression_model
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math import psd_kernels
  from tensorflow_probability.python.math.psd_kernels.internal import test_util
label_desc: Use image node_id 5 for calling the _GaussianProcessTest obj's underlying member method code with example usage: obj.testLateBindingIndexPoints() and returns: unknown