docstr: Compute KL divergence betwen empirical & true distribution.
docstr_tok: ["Compute","KL","divergence","betwen","empirical","&","true","distribution","."]
code: def test_kl_divergence(self, num_samples, kl_tolerance):
      """Compute KL divergence betwen empirical & true distribution."""
      scale = 10
      sq_sigma = scale * scale
      drawn_samples = discrete_gaussian_utils.sample_discrete_gaussian(
          scale=scale, shape=(num_samples,)
      )
      drawn_samples = self.evaluate(drawn_samples)
      value_counts = collections.Counter(drawn_samples)
  
      kl = 0
      norm_const = dgauss_normalizing_constant(sq_sigma)
  
      for value, count in value_counts.items():
          kl += count * (
              math.log(count * norm_const / num_samples)
              + value * value / (2.0 * sq_sigma)
          )
  
      kl /= num_samples
      self.assertLess(kl, kl_tolerance)
  
imports: import collections
  import fractions
  import math
  import random
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import discrete_gaussian_utils
label_desc: Use image node_id 8 for calling the DiscreteGaussianUtilsTest obj's underlying member method code with example usage: obj.test_kl_divergence(num_samples, kl_tolerance) without return types