code: def testBernoulliLikelihood(self):
      kernel = tfpk.ExponentiatedQuadratic()
      num_predictive_points = 10
      num_inducing_points = 5
      num_observations = 15
      vgp = variational_gaussian_process.VariationalGaussianProcess(
          kernel=kernel,
          # 10 predictive locations, 5 inducing points both in 1-d
          index_points=np.random.uniform(
              size=(num_predictive_points, 1)
          ),
          inducing_index_points=np.random.uniform(
              size=(num_inducing_points, 1)
          ),
          # Variational inducing observations posterior normal with mean zero and
          # identity scale.
          variational_inducing_observations_loc=np.zeros(
              num_inducing_points, dtype=np.float64
          ),
          variational_inducing_observations_scale=np.eye(
              num_inducing_points, dtype=np.float64
          ),
          # No observation noise
          observation_noise_variance=0.0,
      )
  
      def log_likelihood_fn(observations, gp_events):
          bern = independent.Independent(
              bernoulli.Bernoulli(logits=gp_events),
              reinterpreted_batch_ndims=1,
          )
          return bern.log_prob(observations)
  
      observations = np.random.randint(2, size=num_observations)
      observation_index_points = np.random.uniform(
          size=(num_observations, 1)
      )
  
      # We really just check that this goes through without any shape errors.
      # TODO(b/127523126): Add more principled tests that this actually computes
      # what we expect it to (manual experimentation and testing has been done and
      # convincing results observed, but no clear strategy for automated tests
      # jumps out as terribly obvious).
      vgp.surrogate_posterior_expected_log_likelihood(
          observations,
          observation_index_points=observation_index_points,
          log_likelihood_fn=log_likelihood_fn,
          quadrature_size=20,
      )
  
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 5 for calling the VariationalGaussianProcessTest obj's underlying member method code with example usage: obj.testBernoulliLikelihood() and returns: bern