code: def testMeanVarianceAndCovariance(self):
      amp = np.float64(0.5)
      len_scale = np.float64(0.2)
      observation_noise_variance = np.float64(1e-3)
      jitter = np.float64(1e-4)
      num_test = 10
      num_obs = 3
      index_points = np.random.uniform(-1.0, 1.0, (num_test, 1)).astype(
          np.float64
      )
      observation_index_points = np.random.uniform(
          -1.0, 1.0, (num_obs, 1)
      ).astype(np.float64)
      observations = np.random.uniform(-1.0, 1.0, 3).astype(np.float64)
  
      # k_xx - k_xn @ (k_nn + sigma^2) @ k_nx + sigma^2
      k = lambda x, y: _np_kernel_matrix_fn(amp, len_scale, x, y)
      k_xx_ = k(index_points, index_points)
      k_xn_ = k(index_points, observation_index_points)
      k_nn_plus_noise_ = k(
          observation_index_points, observation_index_points
      ) + (jitter + observation_noise_variance) * np.eye(num_obs)
  
      expected_predictive_covariance_no_noise = k_xx_ - np.dot(
          k_xn_, np.linalg.solve(k_nn_plus_noise_, k_xn_.T)
      )
  
      expected_predictive_covariance_with_noise = (
          expected_predictive_covariance_no_noise
          + np.eye(num_test) * observation_noise_variance
      )
  
      mean_fn = lambda x: x[:, 0] ** 2
      prior_mean = mean_fn(observation_index_points)
      expected_mean = mean_fn(index_points) + np.dot(
          k_xn_,
          np.linalg.solve(k_nn_plus_noise_, observations - prior_mean),
      )
  
      kernel = exponentiated_quadratic.ExponentiatedQuadratic(
          amp, len_scale
      )
      dist = gprm.GaussianProcessRegressionModel(
          kernel=kernel,
          index_points=index_points,
          observation_index_points=observation_index_points,
          observations=observations,
          observation_noise_variance=observation_noise_variance,
          mean_fn=mean_fn,
          jitter=jitter,
          validate_args=True,
      )
  
      self.assertAllClose(
          expected_predictive_covariance_with_noise,
          self.evaluate(dist.covariance()),
      )
      self.assertAllClose(
          np.diag(expected_predictive_covariance_with_noise),
          self.evaluate(dist.variance()),
      )
      self.assertAllClose(expected_mean, self.evaluate(dist.mean()))
  
      flat = tf.nest.flatten(dist, expand_composites=True)
      unflat = tf.nest.pack_sequence_as(
          dist, flat, expand_composites=True
      )
  
      x = self.evaluate(dist.sample(3, seed=test_util.test_seed()))
      actual = self.evaluate(dist.log_prob(x))
      self.assertAllClose(self.evaluate(unflat.log_prob(x)), actual)
  
      dist_no_predictive_noise = gprm.GaussianProcessRegressionModel(
          kernel=kernel,
          index_points=index_points,
          observation_index_points=observation_index_points,
          observations=observations,
          observation_noise_variance=observation_noise_variance,
          predictive_noise_variance=0.0,
          mean_fn=mean_fn,
          jitter=jitter,
          validate_args=True,
      )
  
      self.assertAllClose(
          expected_predictive_covariance_no_noise,
          self.evaluate(dist_no_predictive_noise.covariance()),
      )
      self.assertAllClose(
          np.diag(expected_predictive_covariance_no_noise),
          self.evaluate(dist_no_predictive_noise.variance()),
      )
      self.assertAllClose(
          expected_mean, self.evaluate(dist_no_predictive_noise.mean())
      )
  
imports: from unittest import mock
  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.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math.psd_kernels import exp_sin_squared
  from tensorflow_probability.python.math.psd_kernels import exponentiated_quadratic
  from tensorflow_probability.python.math.psd_kernels.internal import test_util
label_desc: Use image node_id 2 for calling the _GaussianProcessRegressionModelTest obj's underlying member method code with example usage: obj.testMeanVarianceAndCovariance() without return types