code: def testScanSumEquivalenceWithSeqLen(self):
      with self.test_session() as sess:
          sequence_lengths = [0, 2]
          bootstrap = tf.constant([0.5, 1.5], dtype=tf.float32)
  
          sequence = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
          decays = [
              [0.1, 0.2, 0.3, 0.4, 0.5],
              [0.6, 0.7, 0.8, 0.9, 0.10],
          ]
  
          eq_sequence = [[0, 0, 0, 0, 0], [6, 7, 0, 0, 0]]
          eq_decays = [[0, 0, 0, 0, 0], [0.6, 0.7, 0, 0, 0]]
  
          eq_reverse_sequence = [[0, 0, 0, 0, 0], [7, 6, 0, 0, 0]]
          eq_reverse_decays = [[0, 0, 0, 0, 0], [0.7, 0.6, 0, 0, 0]]
  
          # We use transpose because it is easier to define the input data in
          # BxT (batch x time) form, while scan_discounted_sum assumes TxB form.
          sequence_in = tf.transpose(
              tf.constant(sequence, dtype=tf.float32)
          )
          decays_in = tf.transpose(
              tf.constant(decays, dtype=tf.float32)
          )
          eq_sequence_in = tf.transpose(
              tf.constant(eq_sequence, dtype=tf.float32)
          )
          eq_decays_in = tf.transpose(
              tf.constant(eq_decays, dtype=tf.float32)
          )
          eq_reverse_sequence_in = tf.transpose(
              tf.constant(eq_reverse_sequence, dtype=tf.float32)
          )
          eq_reverse_decays_in = tf.transpose(
              tf.constant(eq_reverse_decays, dtype=tf.float32)
          )
  
          eq_result = sequence_ops.scan_discounted_sum(
              sequence_in,
              decays_in,
              bootstrap,
              reverse=False,
              sequence_lengths=sequence_lengths,
          )
          exp_eq_result = sequence_ops.scan_discounted_sum(
              eq_sequence_in, eq_decays_in, bootstrap
          )
  
          eq_reverse_result = sequence_ops.scan_discounted_sum(
              sequence_in,
              decays_in,
              bootstrap,
              reverse=True,
              sequence_lengths=sequence_lengths,
          )
          exp_eq_reverse_result = sequence_ops.scan_discounted_sum(
              eq_reverse_sequence_in, eq_reverse_decays_in, bootstrap
          )
          exp_eq_reverse_result = tf.reverse_sequence(
              exp_eq_reverse_result,
              sequence_lengths,
              seq_axis=0,
              batch_axis=1,
          )
  
          self.assertAllClose(
              sess.run(eq_result), sess.run(exp_eq_result)
          )
          self.assertAllClose(
              sess.run(eq_reverse_result),
              sess.run(exp_eq_reverse_result),
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from six.moves import xrange
  import tensorflow.compat.v1
  from trfl import sequence_ops
label_desc: Use image node_id 5 for calling the ScanDiscountedSumTest obj's underlying member method code with example usage: obj.testScanSumEquivalenceWithSeqLen() without return types