code: def test_gp_expected_improvement(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)
      best_observed = tf.reduce_max(observations)
  
      exploration = self.dtype(0.1)
      expected_ei = expected_improvement.normal_expected_improvement(
          best_observed=best_observed,
          mean=loc,
          stddev=stddev,
          exploration=exploration,
      )
      gp_ei = expected_improvement.GaussianProcessExpectedImprovement(
          predictive_distribution=model,
          observations=observations,
          exploration=exploration,
      )
      actual_ei, grads = self.evaluate(
          gradient.value_and_gradient(
              lambda x: gp_ei(index_points=x),
              tf.convert_to_tensor(index_points),
          )
      )
  
      self.assertAllClose(actual_ei, expected_ei)
      self.assertAllNotNan(grads)
      self.assertDTypeEqual(actual_ei, self.dtype)
  
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.distributions import student_t
  from tensorflow_probability.python.distributions import student_t_process_regression_model
  from tensorflow_probability.python.experimental.bayesopt.acquisition import expected_improvement
  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 _ExpectedImprovementTest obj's underlying member method code with example usage: obj.test_gp_expected_improvement() without return types