code: def testEntropyGradient(self):
      with self.cached_session() as sess:
          logits = constant_op.constant(
              [[1.0, 2.0, 3.0], [2.0, 5.0, 1.0]]
          )
  
          probabilities = nn_ops.softmax(logits)
          log_probabilities = nn_ops.log_softmax(logits)
          true_entropy = -math_ops.reduce_sum(
              probabilities * log_probabilities, axis=-1
          )
  
          categorical_distribution = categorical.Categorical(
              probs=probabilities
          )
          categorical_entropy = categorical_distribution.entropy()
  
          # works
          true_entropy_g = gradients_impl.gradients(
              true_entropy, [logits]
          )
          categorical_entropy_g = gradients_impl.gradients(
              categorical_entropy, [logits]
          )
  
          res = sess.run(
              {
                  "true_entropy": true_entropy,
                  "categorical_entropy": categorical_entropy,
                  "true_entropy_g": true_entropy_g,
                  "categorical_entropy_g": categorical_entropy_g,
              }
          )
          self.assertAllClose(
              res["true_entropy"], res["categorical_entropy"]
          )
          self.assertAllClose(
              res["true_entropy_g"], res["categorical_entropy_g"]
          )
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops.distributions import categorical
  from tensorflow.python.ops.distributions import kullback_leibler
  from tensorflow.python.ops.distributions import normal
  from tensorflow.python.platform import test
label_desc: Use image node_id 17 for calling the CategoricalTest obj's underlying member method code with example usage: obj.testEntropyGradient() without return types