def retrieve_seq_length_op(data):
 with tf.name_scope('GetLength'):
  used = tf.sign(tf.reduce_max(tf.abs(data), reduction_indices=2))
  length = tf.reduce_sum(used, reduction_indices=1)
  length = tf.cast(length, tf.int32)
 return length

def retrieve_seq_length_op ( data ) : with tf . name_scope ( 'GetLength' ) : used = tf . sign ( tf . reduce_max ( tf . abs ( data ) , reduction_indices = 2 ) ) length = tf . reduce_sum ( used , reduction_indices = 1 ) length = tf . cast ( length , tf . int32 ) return length
an op to compute the length of a sequence from input shape of [batch_size .