class_docstr: Test for `sqe2seq.losses.sequence_mask`.
class_docstr_tok: ["Test","for","`","sqe2seq.losses.sequence_mask","`","."]
code: def test_op(self):
      logits = np.random.randn(
          self.sequence_length, self.batch_size, self.vocab_size
      )
      logits = logits.astype(np.float32)
      sequence_length = np.array([1, 2, 3, 4])
      targets = np.random.randint(
          0, self.vocab_size, [self.sequence_length, self.batch_size]
      )
      losses = seq2seq_losses.cross_entropy_sequence_loss(
          logits, targets, sequence_length
      )
  
      with self.test_session() as sess:
          losses_ = sess.run(losses)
  
      # Make sure all losses not past the sequence length are > 0
      np.testing.assert_array_less(
          np.zeros_like(losses_[:1, 0]), losses_[:1, 0]
      )
      np.testing.assert_array_less(
          np.zeros_like(losses_[:2, 1]), losses_[:2, 1]
      )
      np.testing.assert_array_less(
          np.zeros_like(losses_[:3, 2]), losses_[:3, 2]
      )
  
      # Make sure all losses past the sequence length are 0
      np.testing.assert_array_equal(
          losses_[1:, 0], np.zeros_like(losses_[1:, 0])
      )
      np.testing.assert_array_equal(
          losses_[2:, 1], np.zeros_like(losses_[2:, 1])
      )
      np.testing.assert_array_equal(
          losses_[3:, 2], np.zeros_like(losses_[3:, 2])
      )
  
file_path: seq2seq/seq2seq/test/losses_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from seq2seq import losses
  import tensorflow
  import numpy
label_desc: Use image node_id 2 for calling the CrossEntropySequenceLossTest obj's underlying member method code with example usage: obj.test_op() without return types