code: def testConsistentGradientsFullCovariance(self):
      dist_type = tfp.distributions.MultivariateNormalFullCovariance
      dist1, dist1_mean, dist1_cov = self._create_gaussian(dist_type)
      dist2, dist2_mean, dist2_cov = self._create_gaussian(dist_type)
  
      kl = tfp.distributions.kl_divergence(dist1, dist2)
      kl_mean, kl_cov = distribution_ops.factorised_kl_gaussian(
          dist1_mean,
          dist1_cov,
          dist2_mean,
          dist2_cov,
          both_diagonal=False,
      )
  
      dist1_cov = dist1.parameters["covariance_matrix"]
      dist2_cov = dist2.parameters["covariance_matrix"]
      dist_params = [
          dist1_mean,
          dist2_mean,
          dist1_cov,
          dist2_cov,
      ]
      actual_kl_gradients = tf.gradients(kl, dist_params)
      factorised_kl_gradients = tf.gradients(
          kl_mean + kl_cov, dist_params
      )
  
      # Check that no gradients flow into the mean terms from `kl_cov` and
      # vice-versa.
      gradients = tf.gradients(kl_mean, [dist1_cov])
      self.assertListEqual(gradients, [None])
      gradients = tf.gradients(kl_cov, [dist1_mean, dist2_mean])
      self.assertListEqual(gradients, [None, None])
  
      with self.test_session() as sess:
          np_actual_kl, np_factorised_kl = sess.run(
              [actual_kl_gradients, factorised_kl_gradients]
          )
          self.assertAllClose(np_actual_kl, np_factorised_kl)
  
file_path: trfl/trfl/distribution_ops_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  from absl.testing import parameterized
  import tensorflow.compat.v1
  import tensorflow_probability
  from trfl import distribution_ops
label_desc: Use image node_id 5 for calling the FactorisedKLGaussianTest obj's underlying member method code with example usage: obj.testConsistentGradientsFullCovariance() without return types