class_docstr: Tests mle losses.
      
code: def _test_sequence_loss(
      self, loss_fn, labels, logits, sequence_length
  ):
      with self.test_session() as sess:
          loss = loss_fn(labels, logits, sequence_length)
          rank = sess.run(tf.rank(loss))
          self.assertEqual(rank, 0)
  
          loss = loss_fn(
              labels, logits, sequence_length, sum_over_timesteps=False
          )
          rank = sess.run(tf.rank(loss))
          self.assertEqual(rank, 1)
          self.assertEqual(loss.shape, tf.TensorShape([self._max_time]))
  
          loss = loss_fn(
              labels,
              logits,
              sequence_length,
              sum_over_timesteps=False,
              average_across_timesteps=True,
              average_across_batch=False,
          )
          rank = sess.run(tf.rank(loss))
          self.assertEqual(rank, 1)
          self.assertEqual(
              loss.shape, tf.TensorShape([self._batch_size])
          )
  
          loss = loss_fn(
              labels,
              logits,
              sequence_length,
              sum_over_timesteps=False,
              average_across_batch=False,
          )
          rank = sess.run(tf.rank(loss))
          self.assertEqual(rank, 2)
          self.assertEqual(
              loss.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
          )
          loss = loss_fn(
              labels,
              logits,
              sequence_length_time,
              sum_over_timesteps=False,
              average_across_batch=False,
              time_major=True,
          )
          self.assertEqual(
              loss.shape,
              tf.TensorShape([self._batch_size, self._max_time]),
          )
  
file_path: texar/tests/losses/mle_losses_test.py
imports: import numpy
  import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling the MLELossesTest obj's underlying member method code with example usage: obj._test_sequence_loss(loss_fn, labels, logits, sequence_length) without return types