code: def testOptimalVariationalShapes(self, is_static):
      # 5x5 grid of observation index points in R^2 and flatten to 25x2
      observation_index_points = np.linspace(
          -4.0, 4.0, 5, dtype=np.float64
      )
      observation_index_points = np.stack(
          np.meshgrid(
              observation_index_points, observation_index_points
          ),
          axis=-1,
      )
      observation_index_points = np.reshape(
          observation_index_points, [-1, 2]
      )
      # ==> shape = [25, 2]
      observation_index_points = np.expand_dims(
          np.stack([observation_index_points] * 6), -3
      )
      # ==> shape = [6, 1, 25, 2]
      observations = np.sin(observation_index_points[..., 0])
      # ==> shape = [6, 1, 25]
  
      # 9 inducing index points in R^2
      inducing_index_points = np.linspace(
          -4.0, 4.0, 3, dtype=np.float64
      )
      inducing_index_points = np.stack(
          np.meshgrid(inducing_index_points, inducing_index_points),
          axis=-1,
      )
      inducing_index_points = np.reshape(inducing_index_points, [-1, 2])
      # ==> shape = [9, 2]
  
      # Kernel with batch_shape [2, 4, 1, 1]
      amplitude = np.array([1.0, 2.0], np.float64).reshape([2, 1, 1, 1])
      length_scale = np.array([0.1, 0.2, 0.3, 0.4], np.float64).reshape(
          [1, 4, 1, 1]
      )
  
      jitter = np.float64(1e-6)
      observation_noise_variance = np.float64(1e-2)
  
      if not is_static:
          amplitude = tf1.placeholder_with_default(
              amplitude, shape=None
          )
          length_scale = tf1.placeholder_with_default(
              length_scale, shape=None
          )
          observation_index_points = tf1.placeholder_with_default(
              observation_index_points, shape=None
          )
  
          inducing_index_points = tf1.placeholder_with_default(
              inducing_index_points, shape=None
          )
      kernel = tfpk.ExponentiatedQuadratic(amplitude, length_scale)
  
      (
          loc,
          scale,
      ) = variational_gaussian_process.VariationalGaussianProcess.optimal_variational_posterior(
          kernel=kernel,
          inducing_index_points=inducing_index_points,
          observation_index_points=observation_index_points,
          observations=observations,
          observation_noise_variance=observation_noise_variance,
          jitter=jitter,
      )
      # We should expect that loc has shape [2, 4, 6, 1, 9]. This is because:
      # * [2, 4] comes from the batch shape of the kernel.
      # * [6, 1] comes from the batch shape of the observations / observation
      # index points.
      # * [9] comes from the number of inducing points.
      # Similar reasoning applies to scale.
      self.assertAllEqual([2, 4, 6, 1, 9], tf.shape(loc))
      self.assertAllEqual([2, 4, 6, 1, 9, 9], tf.shape(scale))
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import variational_gaussian_process
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math.psd_kernels import exponentiated_quadratic
label_desc: Use image node_id 2 for calling the VariationalGaussianProcessTest obj's underlying member method code with example usage: obj.testOptimalVariationalShapes(is_static) without return types