class_docstr: RNN model for text classification.
class_docstr_tok: ["RNN","model","for","text","classification","."]
docstr: count sequence length.
  input: [batch_size, max_len]
  lens: [batch_size]
docstr_tok: ["count","sequence","length",".","input",":","[","batch_size",",","max_len","]","lens",":","[","batch_size","]"]
code: def compute_lens(inputs, max_len):
      """count sequence length.
      input: [batch_size, max_len]
      lens: [batch_size]
      """
  
      x_binary = tf.cast(
          tf.cast(tf.reverse(inputs, axis=[1]), tf.bool), tf.int32
      )
      lens = max_len - tf.argmax(x_binary, axis=1, output_type=tf.int32)
  
      zeros = tf.zeros_like(lens, dtype=tf.int32)
      x_sum = tf.reduce_sum(inputs, axis=1)
      sen_lens = tf.where(tf.equal(x_sum, 0), zeros, lens)
      return sen_lens
  
imports: import pickle
  import delta.compat
  from absl import logging
  from delta import layers
  from delta.models.text_cls_model import TextClassModel
  from delta.utils.register import registers
  from delta import utils
label_desc: Use image node_id 2 for calling the RnnAttentionModel obj's underlying member method code with example usage: obj.compute_lens(inputs, max_len) and returns: sen_lens