class_docstr: Tests entropy.
      
code: def _test_entropy(self, entropy_fn, logits, sequence_length=None):
      with self.test_session() as sess:
          if sequence_length is None:
              entropy = entropy_fn(logits)
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 0)
  
              entropy = entropy_fn(logits, average_across_batch=False)
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 1)
              self.assertEqual(
                  entropy.shape, tf.TensorShape([self._batch_size])
              )
          else:
              entropy = entropy_fn(
                  logits, sequence_length=sequence_length
              )
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 0)
  
              entropy = entropy_fn(
                  logits,
                  sequence_length=sequence_length,
                  sum_over_timesteps=False,
              )
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 1)
              self.assertEqual(
                  entropy.shape, tf.TensorShape([self._max_time])
              )
  
              entropy = entropy_fn(
                  logits,
                  sequence_length=sequence_length,
                  sum_over_timesteps=False,
                  average_across_timesteps=True,
                  average_across_batch=False,
              )
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 1)
              self.assertEqual(
                  entropy.shape, tf.TensorShape([self._batch_size])
              )
  
              entropy = entropy_fn(
                  logits,
                  sequence_length=sequence_length,
                  sum_over_timesteps=False,
                  average_across_batch=False,
              )
              rank = sess.run(tf.rank(entropy))
              self.assertEqual(rank, 2)
              self.assertEqual(
                  entropy.shape,
                  tf.TensorShape([self._batch_size, self._max_time]),
              )
  
              sequence_length_time = tf.random_uniform(
                  [self._max_time],
                  maxval=self._batch_size,
                  dtype=tf.int32,
              )
              entropy = entropy_fn(
                  logits,
                  sequence_length=sequence_length_time,
                  sum_over_timesteps=False,
                  average_across_batch=False,
                  time_major=True,
              )
              self.assertEqual(
                  entropy.shape,
                  tf.TensorShape([self._batch_size, self._max_time]),
              )
  
imports: import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling the EntropyTest obj's underlying member method code with example usage: obj._test_entropy(entropy_fn, logits, sequence_length) without return types