code: def test_gp_upper_confidence_bound(self):
      observation_index_points = np.linspace(
          1.0, 10.0, 20, dtype=self.dtype
      ).reshape(5, 4)
      observations = np.sum(observation_index_points, axis=-1)
      index_points = np.linspace(
          4.0, 5.0, 12, dtype=self.dtype
      ).reshape(3, 4)
      kernel = exponentiated_quadratic.ExponentiatedQuadratic(
          self.dtype(1.0), 1.0
      )
  
      model = gaussian_process_regression_model.GaussianProcessRegressionModel(
          kernel=kernel,
          observations=observations,
          observation_index_points=observation_index_points,
      )
  
      loc = model.mean(index_points=index_points)
      stddev = model.stddev(index_points=index_points)
  
      exploration = 0.1
      expected_ucb = (
          upper_confidence_bound.normal_upper_confidence_bound(
              mean=loc, stddev=stddev, exploration=exploration
          )
      )
      gp_ucb = (
          upper_confidence_bound.GaussianProcessUpperConfidenceBound(
              predictive_distribution=model,
              observations=observations,
              exploration=exploration,
          )
      )
      actual_ucb, grads = self.evaluate(
          gradient.value_and_gradient(
              lambda x: gp_ucb(index_points=x),
              tf.convert_to_tensor(index_points),
          )
      )
      self.assertAllClose(actual_ucb, expected_ucb)
      self.assertAllNotNan(grads)
      self.assertDTypeEqual(actual_ucb, self.dtype)
  
file_path: probability/tensorflow_probability/python/experimental/bayesopt/acquisition/upper_confidence_bound_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import gaussian_process_regression_model
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.experimental.bayesopt.acquisition import upper_confidence_bound
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math.psd_kernels import exponentiated_quadratic
label_desc: Use image node_id 2 for calling the _UpperConfidenceBoundTest obj's underlying member method code with example usage: obj.test_gp_upper_confidence_bound() without return types