import tensorflow as tf


    # Make a matrix where each row contains [0, 1, ..., max_sequence_len]
    r = tf.range(0, max_sequence_len, 1)
    range_row = tf.expand_dims(r, 0)
    range_tiled = tf.tile(range_row, [batch_size, 1])

    # Use the logical operations to create a mask
    indicator = tf.less(range_tiled, lengths_tiled)
    sz = [batch_size, max_sequence_len]
    self._mask = tf.select(indicator, tf.ones(sz), tf.zeros(sz))

  def _DoPredictions(self, in_size, mats, class_weights=None):
    """Takes in an array of states and calculates predictions.

    Get the cross-entropy for each example in the vector self._xent.

    Args:
      in_size: size of the hidden state vectors
