code: def retrieve_seq_length_op2(data):
      """An op to compute the length of a sequence, from input shape of [batch_size, n_step(max)],
      it can be used when the features of padding (on right hand side) are all zeros.
  
      Parameters
      -----------
      data : tensor
          [batch_size, n_step(max)] with zero padding on right hand side.
  
      Examples
      -----------
      >>> data = [[1,2,0,0,0],
      >>>         [1,2,3,0,0],
      >>>         [1,2,6,1,0]]
      >>> data = tf.convert_to_tensor(data, dtype=tf.float32)
      >>> length = tl.layers.retrieve_seq_length_op2(data)
      tensor([2 3 4])
  
      """
      return tf.reduce_sum(
          input_tensor=tf.cast(
              tf.greater(data, tf.zeros_like(data)), tf.int32
          ),
          axis=1,
      )
  
imports: import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated_alias
  from tensorlayer.layers.core import Layer
label_desc: Use image node_id 2 for calling a global function with example usage: retrieve_seq_length_op2(data) and returns: tf