code: def test_lower_bound_barber_agakov(self):
      # Test1: against numpy reimplementation
      test_scores = tf.random.normal(
          shape=[
              100,
          ],
          stddev=5.0,
      )
      test_entropy = tf.random.normal(shape=[], stddev=10.0)
      impl_estimation, test_scores, test_entropy = self.evaluate(
          [
              mi.lower_bound_barber_agakov(
                  logu=test_scores, entropy=test_entropy
              ),
              test_scores,
              test_entropy,
          ]
      )
      numpy_estimation = np.mean(test_scores) + test_entropy
      self.assertAllClose(impl_estimation, numpy_estimation)
  
      # Test2: batched input
      test_scores_2 = tf.random.normal(shape=[13, 5], stddev=5.0)
      test_entropy_2 = tf.random.normal(
          shape=[
              13,
          ],
          stddev=10.0,
      )
      impl_estimation_2, test_scores_2, test_entropy_2 = self.evaluate(
          [
              mi.lower_bound_barber_agakov(
                  logu=test_scores_2, entropy=test_entropy_2
              ),
              test_scores_2,
              test_entropy_2,
          ]
      )
      numpy_estimation_2 = (
          np.mean(test_scores_2, axis=-1) + test_entropy_2
      )
      self.assertAllClose(impl_estimation_2, numpy_estimation_2)
  
      # Test3: test example, since the estimation is a lower bound, we test
      # by range.
      impl_estimation_3 = self.evaluate(
          mi.lower_bound_barber_agakov(
              logu=tf.linalg.diag_part(self.conditional_scores),
              entropy=self.differential_entropy_y,
          )
      )
      self.assertAllInRange(
          impl_estimation_3,
          self.theoretical_mi - LOWER_BOUND_MIN_GAP,
          self.theoretical_mi + LOWER_BOUND_MAX_GAP,
      )
  
file_path: probability/tensorflow_probability/python/vi/mutual_information_test.py
imports: import numpy
  import scipy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.vi import mutual_information
label_desc: Use image node_id 5 for calling the MutualInformationTest obj's underlying member method code with example usage: obj.test_lower_bound_barber_agakov() without return types