code: def _reverse_seq(sequence, sequence_lengths=None):
      """Reverse sequence along dim 0.
  
      Args:
        sequence: Tensor of shape [T, B, ...].
        sequence_lengths: (optional) tensor of shape [B]. If `None`, only reverse
          along dim 0.
  
      Returns:
        Tensor of same shape as sequence with dim 0 reversed up to sequence_lengths.
      """
      if sequence_lengths is None:
          return tf.reverse(sequence, [0])
  
      sequence_lengths = tf.convert_to_tensor(sequence_lengths)
      with tf.control_dependencies(
          [
              tf.assert_equal(
                  sequence.shape[1], sequence_lengths.shape[0]
              )
          ]
      ):
          return tf.reverse_sequence(
              sequence, sequence_lengths, seq_axis=0, batch_axis=1
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: _reverse_seq(sequence, sequence_lengths) and returns: tf, tf