import tensorflow as tf


            shape = [batch_size, passage_length, extended_vsize]
            shape = tf.cast(shape, tf.int64)

            attn_dist = tf.reshape(attn_dist, shape=[-1]) # [batch_size*passage_length]
            one_hot_spare_rep = tf.SparseTensor(indices=indices, values=attn_dist, dense_shape=shape) # [batch_size, passage_length, extended_vsize]

            if passage_mask is not None:
                passage_mask = tf.expand_dims(passage_mask, axis=-1)
                one_hot_spare_rep = one_hot_spare_rep * passage_mask

            one_hot_spare_rep = tf.sparse_reduce_sum(one_hot_spare_rep, axis=1) # [batch_size, extended_vsize]
            vocab_dist = tf.add(vocab_dist, one_hot_spare_rep)

            if self.options.add_first_word_prob_for_phrase:
                vocab_dist = tf.nn.softmax(vocab_dist) # normalize

        return vocab_dist # [batch_size, extended_vsize]

def linear(args, output_size, bias=True, bias_start=0.0, scope=None):
    if args is None or (isinstance(args, (list, tuple)) and not args):
        raise ValueError("`args` must be specified")
