import tensorflow as tf

    range_tiled = tf.tile(range_row, [batch_size, 1])

    self.lengths_transposed = lengths_transposed
    self.lengths_tiled = lengths_tiled
    self.range_row = range_row
    self.range_tiled = range_tiled

    # Use the logical operations to create a mask
    indicator = tf.less(range_tiled, lengths_tiled+1) #i.e. where seq len is less than index
    trim = np.ones(indicator.get_shape())
    trim[:,0] = 0 #ignore start symbol
    indicator = tf.logical_and(indicator, trim.astype(bool))
    self.indicator = indicator

    sz = [batch_size, max_sequence_len]
    self._mask = tf.select(indicator, tf.ones(sz), tf.zeros(sz))

    #-------------------------------#

    self.weights = tf.constant(weights, dtype=tf.float32, name='class_weights')

    hidden_size = model_params['model_hidden_size']
    proj_size = model_params['model_proj_size']  # optional, can be None

    def GetCell():
      """Creates an LSTM cell with dropout."""
      c = tf.nn.rnn_cell.LSTMCell(hidden_size,
                                  use_peepholes=model_params['peepholes'],
                                  num_proj=proj_size)
      if dropout_keep_prob is not None:
