class_docstr: Tests for discrete_policy_entropy op.
class_docstr_tok: ["Tests","for","discrete_policy_entropy","op","."]
code: def testEntropy(self, is_multi_actions):
      with self.test_session() as sess:
          # Large values check numerical stability through the logs
          policy_logits_np = np.array(
              [[0, 1], [1, 2], [0, 2], [1, 1], [0, -1000], [0, 1000]]
          )
          if is_multi_actions:
              num_action_components = 3
              policy_logits_nest = [
                  tf.constant(policy_logits_np, dtype=tf.float32)
                  for _ in xrange(num_action_components)
              ]
          else:
              num_action_components = 1
              policy_logits_nest = tf.constant(
                  policy_logits_np, dtype=tf.float32
              )
  
          entropy_op = pg_ops.discrete_policy_entropy_loss(
              policy_logits_nest
          )
          entropy = entropy_op.extra.entropy
          self.assertEqual(entropy.get_shape(), tf.TensorShape(6))
          # Get these reference values in Torch with:
          #   c = nnd.EntropyCriterion()
          #   s = nn.LogSoftMax()
          #   result = c:forward(s:forward(logits))
          expected_entropy = num_action_components * np.array(
              [0.58220309, 0.58220309, 0.36533386, 0.69314718, 0, 0]
          )
          self.assertAllClose(
              sess.run(entropy), expected_entropy, atol=1e-4
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  from six.moves import xrange
  import tensorflow.compat.v1
  import tree
  from trfl import discrete_policy_gradient_ops
label_desc: Use image node_id 1 for calling the EntropyCostTest obj's underlying member method code with example usage: obj.testEntropy(is_multi_actions) without return types