import tensorflow as tf

    # [time_steps, batch_size, dimension].
    chars = tf.transpose(chars, [1, 0, 2])
    # The outer loop cycles through the layers of the RNN; the inner loop
    # executes the time steps for a particular layer.
    batch_size = int(chars.shape[1])
    for l in range(len(self.cells)):
      cell = self.cells[l]
      outputs = []
      state = cell.zero_state(batch_size, tf.float32)
      # Unstack the inputs to obtain a list of batches, one for each time step.
      chars = tf.unstack(chars, axis=0)
      for ch in chars:
        output, state = cell(ch, state)
        outputs.append(output)
      # The outputs of this layer are the inputs of the subsequent layer.
      chars = tf.stack(outputs, axis=0)
      if training:
        chars = tf.nn.dropout(chars, self.keep_prob)
    # Extract the correct output (i.e., hidden state) for each example. All the
    # character sequences in this batch were padded to the same fixed length so
