class_docstr: Tests pg losses.
      
code: def _test_sequence_loss(
      self,
      loss_fn,
      actions,
      logits,
      advantages,
      batched,
      sequence_length,
  ):
      with self.test_session() as sess:
          loss = loss_fn(
              actions,
              logits,
              advantages,
              batched=batched,
              sequence_length=sequence_length,
          )
          rank = sess.run(tf.rank(loss))
          self.assertEqual(rank, 0)
  
          loss = loss_fn(
              actions,
              logits,
              advantages,
              batched=batched,
              sequence_length=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(
              actions,
              logits,
              advantages,
              batched=batched,
              sequence_length=sequence_length,
              sum_over_timesteps=False,
              average_across_timesteps=True,
              average_across_batch=False,
          )
          rank = sess.run(tf.rank(loss))
          if batched:
              self.assertEqual(rank, 1)
              self.assertEqual(
                  loss.shape, tf.TensorShape([self._batch_size])
              )
          else:
              self.assertEqual(rank, 0)
  
          loss = loss_fn(
              actions,
              logits,
              advantages,
              batched=batched,
              sequence_length=sequence_length,
              sum_over_timesteps=False,
              average_across_batch=False,
          )
          rank = sess.run(tf.rank(loss))
          if batched:
              self.assertEqual(rank, 2)
              self.assertEqual(
                  loss.shape,
                  tf.TensorShape([self._batch_size, self._max_time]),
              )
          else:
              self.assertEqual(rank, 1)
              self.assertEqual(
                  loss.shape, tf.TensorShape([self._max_time])
              )
  
          sequence_length_time = tf.random_uniform(
              [self._max_time], maxval=self._max_time, dtype=tf.int32
          )
          loss = loss_fn(
              actions,
              logits,
              advantages,
              batched=batched,
              sequence_length=sequence_length_time,
              sum_over_timesteps=False,
              average_across_batch=False,
              time_major=True,
          )
          if batched:
              self.assertEqual(
                  loss.shape,
                  tf.TensorShape([self._batch_size, self._max_time]),
              )
          else:
              self.assertEqual(
                  loss.shape, tf.TensorShape([self._max_time])
              )
  
imports: import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling the PGLossesTest obj's underlying member method code with example usage: obj._test_sequence_loss(loss_fn, actions, logits, advantages, batched, sequence_length) without return types