code: def mask_sequences(
      sequence,
      sequence_length,
      dtype=None,
      time_major=False,
      tensor_rank=2,
  ):
      """Masks out sequence entries that are beyond the respective sequence
      lengths. Masks along the time dimension.
  
      :attr:`sequence` and :attr:`sequence_length` can either be python
      arrays or Tensors, respectively. If both are python arrays (or None), the
      return will be a python array as well.
  
      Args:
          sequence: A Tensor or python array of sequence values.
              If `time_major==False` (default), this must be a Tensor of shape
              `[batch_size, max_time, ...]`. The batch and time dimension is
              exchanged if `time_major==True`.
          sequence_length: A Tensor or python array of shape `[batch_size]`.
              Time steps beyond the respective sequence lengths will be
              made zero.
          dtype (dtype): Type of :attr:`sequence`. If `None`, infer from
              :attr:`sequence` automatically.
          time_major (bool): The shape format of the inputs. If `True`,
              :attr:`sequence` must have shape
              `[max_time, batch_size, ...]`.
              If `False` (default), :attr:`sequence` must have
              shape `[batch_size, max_time, ...]`.
          tensor_rank (int): The number of dimensions of :attr:`sequence`.
              Default is 2, i.e., :attr:`sequence` is a 2D Tensor consisting
              of batch and time dimensions. Ignored if both :attr:`sequence`
              and :attr:`sequence_length` are python arrays.
  
      Returns:
          The masked sequence, i.e., a Tensor or python array of the same shape
          as :attr:`sequence` but with masked-out entries (set to zero).
  
          If both :attr:`sequence` and :attr:`sequence_length` are python
          arrays, the returned value is a python array as well.
      """
      is_tensor = tf.contrib.framework.is_tensor
      if is_tensor(sequence) or is_tensor(sequence_length):
          return _mask_sequences_tensor(
              sequence, sequence_length, dtype, time_major, tensor_rank
          )
      else:
          return _mask_sequences_py(
              sequence, sequence_length, dtype, time_major
          )
  
file_path: texar/texar/tf/utils/shapes.py
imports: import numpy
  import tensorflow
  from tensorflow.python.util import nest
  from tensorflow.python.ops import rnn
  from tensorflow.python.framework import ops
label_desc: Use image node_id 4 for calling a global function with example usage: mask_sequences(sequence, sequence_length, dtype, time_major, tensor_rank) and returns: _mask_sequences_tensor, _mask_sequences_py