import tensorflow as tf

        # Run the decoder RNN cell. cell_output = decoder state
        cell_output, state_t = self.cell(x, state_t_1)

        context_t, attn_dist, coverage_t = self.attention(state_t, options.attention_vec_size, encoder_states,
                                                             encoder_features, passage_mask, v, w_c=w_c,
                                                             use_coverage=options.use_coverage, coverage=coverage_t_1)
        # Calculate p_gen, Equation (8)
        if options.pointer_gen:
            with tf.variable_scope('calculate_pgen'):
                p_gen = linear([context_t, state_t.c, state_t.h, x], 1, True) # [batch_size, 1]
                p_gen = tf.sigmoid(p_gen)

        # Concatenate the cell_output (= decoder state) and the context vector, and pass them through a linear layer
        # This is V[s_t, h*_t] + b in the paper
        with variable_scope.variable_scope("AttnOutputProjection"):
            output_t = linear([cell_output] + [context_t], options.gen_hidden_size, True)
