code: def test_weighted_power_scalarization(self):
      kernel = exponentiated_quadratic.ExponentiatedQuadratic(
          amplitude=self.dtype(1.0)
      )
      mt_kernel = multitask_kernel.Independent(
          base_kernel=kernel, num_tasks=4
      )
      shape = [5, 1, 20]
      index_points = 2.0 * np.random.uniform(size=shape).astype(
          dtype=self.dtype
      )
      observations = 2.0 * np.random.uniform(size=[10, 4]).astype(
          dtype=self.dtype
      )
      dist = mtgp.MultiTaskGaussianProcess(
          kernel=mt_kernel,
          index_points=index_points,
          observation_noise_variance=1e-4,
      )
  
      weights = np.array([0.8, 1.0, 1.1, 0.5]).astype(self.dtype)
  
      acquisition_function_classes = [
          expected_improvement.GaussianProcessExpectedImprovement,
          upper_confidence_bound.GaussianProcessUpperConfidenceBound,
          expected_improvement.GaussianProcessExpectedImprovement,
          upper_confidence_bound.GaussianProcessUpperConfidenceBound,
      ]
  
      acquisition_kwargs_list = 4 * [None]
  
      cheb_scalar_fn = wps.WeightedPowerScalarization(
          predictive_distribution=dist,
          acquisition_function_classes=acquisition_function_classes,
          acquisition_kwargs_list=acquisition_kwargs_list,
          observations=observations,
          weights=weights,
          seed=test_util.test_seed(),
      )
      actual_cheb_scalar, grad = self.evaluate(
          gradient.value_and_gradient(
              lambda x: cheb_scalar_fn(index_points=x),
              tf.convert_to_tensor(index_points),
          )
      )
  
      gp_per_task = gaussian_process.GaussianProcess(
          kernel=kernel,
          index_points=index_points,
          observation_noise_variance=1e-4,
      )
  
      expected_cheb_scalars = []
      for i in range(4):
          acquisition_kwargs = acquisition_kwargs_list[i]
          if acquisition_kwargs is None:
              acquisition_kwargs = {}
          expected_cheb_scalars.append(
              weights[i]
              * tf.math.abs(
                  acquisition_function_classes[i](
                      predictive_distribution=gp_per_task,
                      observations=observations[..., i],
                      seed=test_util.test_seed(),
                      **acquisition_kwargs,
                  )()
              )
          )
      expected_cheb_scalar = tf.reduce_max(
          tf.concat(expected_cheb_scalars, axis=-1), axis=-1
      )
      self.assertAllNotNan(grad)
      self.assertAllClose(
          actual_cheb_scalar, expected_cheb_scalar, rtol=6e-4
      )
      self.assertDTypeEqual(actual_cheb_scalar, self.dtype)
  
file_path: probability/tensorflow_probability/python/experimental/bayesopt/acquisition/weighted_power_scalarization_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import gaussian_process
  from tensorflow_probability.python.experimental.bayesopt.acquisition import expected_improvement
  from tensorflow_probability.python.experimental.bayesopt.acquisition import upper_confidence_bound
  from tensorflow_probability.python.experimental.bayesopt.acquisition import weighted_power_scalarization
  from tensorflow_probability.python.experimental.distributions import multitask_gaussian_process
  from tensorflow_probability.python.experimental.psd_kernels import multitask_kernel
  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 1 for calling the _WeightedPowerScalarizationTest obj's underlying member method code with example usage: obj.test_weighted_power_scalarization() without return types