import tensorflow as tf

                'softmax_w', [hidden_size, vocab_size], dtype=tf.float32)
            softmax_b = tf.get_variable('softmax_b', [vocab_size], dtype=tf.float32)
            logits = tf.nn.xw_plus_b(output, softmax_w, softmax_b)
            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)
            self._final_state = state

            if not is_training:
                return

            self._lr = tf.Variable(0., trainable=False)
            tvars = tf.trainable_variables()
            grads, _ = tf.clip_by_global_norm(tf.gradients(self._cost, tvars),
                                          config.max_grad_norm)
            optimizer = tf.train.GradientDescentOptimizer(self._lr)
            self._train_op = optimizer.apply_gradients(
