code: def lengths_to_area_mask(feature_length, length, max_area_size):
      """Generates a non-padding mask for areas based on lengths.
  
      Args:
        feature_length: a tensor of [batch_size]
        length: the length of the batch
        max_area_size: the maximum area size considered
      Returns:
        mask: a tensor in shape of [batch_size, num_areas]
      """
  
      paddings = tf.cast(
          tf.expand_dims(
              tf.logical_not(
                  tf.sequence_mask(feature_length, maxlen=length)
              ),
              2,
          ),
          tf.float32,
      )
      _, _, area_sum, _, _ = compute_area_features(
          paddings, max_area_width=max_area_size
      )
      mask = tf.squeeze(tf.logical_not(tf.cast(area_sum, tf.bool)), [2])
      return mask
  
file_path: tensor2tensor/tensor2tensor/layers/area_attention.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from six.moves import range
  from tensor2tensor.layers import common_layers
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: lengths_to_area_mask(feature_length, length, max_area_size) and returns: mask