import tensorflow as tf

            logits = tf.reshape(logits, [self.batch_size, self.num_steps, vocab_size])

            loss = tf.contrib.seq2seq.sequence_loss(
                logits,
                input_.targets,
                tf.ones([self.batch_size, self.num_steps], dtype=tf.float32),
                average_across_timesteps=False,
                average_across_batch=True)

            self._cost = tf.reduce_sum(loss)
