code: def testLogProbMatchesGP(self):
      # Check that the independent kernel parameterization matches using a
      # single-task GP.
      # 5x5 grid of index points in R^2 and flatten to 25x2
      index_points = np.linspace(-4.0, 4.0, 5, dtype=np.float32)
      index_points = np.stack(
          np.meshgrid(index_points, index_points), axis=-1
      )
      index_points = np.reshape(index_points, [-1, 2])
      # ==> shape = [25, 2]
  
      # Kernel with batch_shape [2, 4, 3, 1]
      amplitude = np.array([1.0, 2.0], np.float32).reshape([2, 1, 1, 1])
      length_scale = np.array([1.0, 2.0, 3.0, 4.0], np.float32).reshape(
          [1, 4, 1, 1]
      )
      observation_noise_variance = np.array(
          [1e-5, 1e-6, 1e-5], np.float32
      ).reshape([1, 1, 3, 1])
      batched_index_points = np.stack([index_points] * 6)
      # ==> shape = [6, 25, 2]
      kernel = exponentiated_quadratic.ExponentiatedQuadratic(
          amplitude, length_scale
      )
      multi_task_kernel = multitask_kernel.Independent(
          num_tasks=3, base_kernel=kernel
      )
      multitask_gp = (
          multitask_gaussian_process.MultiTaskGaussianProcess(
              multi_task_kernel,
              batched_index_points,
              observation_noise_variance=observation_noise_variance,
              validate_args=True,
          )
      )
      gp = gaussian_process.GaussianProcess(
          kernel,
          batched_index_points,
          observation_noise_variance=observation_noise_variance,
          validate_args=True,
      )
      observations = (
          np.linspace(-20.0, 20.0, 75).reshape(25, 3).astype(np.float32)
      )
      multitask_log_prob = multitask_gp.log_prob(observations)
      single_task_log_prob = sum(
          gp.log_prob(observations[..., i]) for i in range(3)
      )
      self.assertAllClose(
          self.evaluate(single_task_log_prob),
          self.evaluate(multitask_log_prob),
          rtol=4e-3,
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import gaussian_process
  from tensorflow_probability.python.experimental.distributions import multitask_gaussian_process
  from tensorflow_probability.python.experimental.distributions import multitask_gaussian_process_regression_model
  from tensorflow_probability.python.experimental.psd_kernels import multitask_kernel
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import test_util
  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 8 for calling the MultiTaskGaussianProcessTest obj's underlying member method code with example usage: obj.testLogProbMatchesGP() without return types