import tensorflow as tf

      """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:
        c = tf.nn.rnn_cell.DropoutWrapper(c, input_keep_prob=dropout_keep_prob)
      return c

    # Create the bi-directional LSTM
    with tf.variable_scope('wordrnn'):
      with tf.variable_scope('fw'):
        cell_fw = GetCell()
      with tf.variable_scope('bw'):
        cell_bw = GetCell()

      rnnout, _, _ = tf.nn.bidirectional_rnn(cell_fw, cell_bw, self._inputs,
                                             dtype=tf.float32,
                                             sequence_length=self.seq_lens)
      if proj_size:
        out_size = 2 * proj_size
      else:
        out_size = 2 * hidden_size
      self._DoPredictions(out_size, rnnout, self.weights)

      self.cost = tf.reduce_mean(self.example_weights * self._xent)

  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.
