import tensorflow as tf

    def singel_instance(x):
        cur_passage_words = x[0] # [passage_length]
        cur_phrase_starts = x[1] # [phrase_length]
        cur_vocab_dist = x[2] # [vsize]
        cur_attn_dist = x[3] # [passage_length]
        # first: get the first word for each phrase
        first_words = tf.gather(cur_passage_words, cur_phrase_starts) # [phrase_length]
        # second: get the probs for each word
        first_word_probs = tf.gather(cur_vocab_dist, first_words) # [phrase_length]
        return cur_attn_dist + first_word_probs
    elems = (in_passage_words, phrase_starts, vocab_dist, attn_dist)
    return tf.map_fn(singel_instance, elems, dtype=tf.float32) # [batch_size, phrase_length]


class CovCopyAttenGen:
    def __init__(self, placeholders, options, vocab):
        self.options = options
        self.vocab = vocab
        self.cell = tf.contrib.rnn.LSTMCell(
                    options.gen_hidden_size,
                    initializer=tf.random_uniform_initializer(-0.1, 0.1, seed=113),
                    state_is_tuple=True)
