Returns cost.

    Args:
      logits: model output.
      target: target.

    Returns:
      Cross-entropy loss for a sequence of logits. The loss will be averaged
      across time steps if time_average_cost was enabled at construction time.

def cost(self, logits, target):
    """Returns cost.

    Args:
      logits: model output.
      target: target.

    Returns:
      Cross-entropy loss for a sequence of logits. The loss will be averaged
      across time steps if time_average_cost was enabled at construction time.
    """
    logits = tf.reshape(logits, [self._num_steps * self._batch_size, -1])
    target = tf.reshape(target, [self._num_steps * self._batch_size, -1])
    xent = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=target)
    loss = tf.reduce_sum(xent)

    return loss / self._batch_size