code: def retrieve_seq_length_op(data):
      """An op to compute the length of a sequence from input shape of [batch_size, n_step(max), n_features],
      it can be used when the features of padding (on right hand side) are all zeros.
  
      Parameters
      -----------
      data : tensor
          [batch_size, n_step(max), n_features] with zero padding on right hand side.
  
      Examples
      -----------
      Single feature
  
      >>> 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_op(data)
      [2 3 4]
  
      Multiple features
  
      >>> data = [[[1,2],[2,2],[1,2],[1,2],[0,0]],
      >>>          [[2,3],[2,4],[3,2],[0,0],[0,0]],
      >>>          [[3,3],[2,2],[5,3],[1,2],[0,0]]]
      >>> data = tf.convert_to_tensor(data, dtype=tf.float32)
      >>> length = tl.layers.retrieve_seq_length_op(data)
      [4 3 4]
  
      References
      ------------
      Borrow from `TFlearn <https://github.com/tflearn/tflearn/blob/master/tflearn/layers/recurrent.py>`__.
  
      """
      with tf.name_scope("GetLength"):
          used = tf.sign(
              tf.reduce_max(input_tensor=tf.abs(data), axis=2)
          )
          length = tf.reduce_sum(input_tensor=used, axis=1)
  
          return tf.cast(length, tf.int32)
  
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 1 for calling a global function with example usage: retrieve_seq_length_op(data) and returns: tf