import tensorflow as tf

        pos_feats = tf.to_float(tf.stack([src_pos, trg_pos, src_len], axis=2))
        pos_feats = tf.log(1 + pos_feats)

        y += dense(pos_feats, encoder.attn_size, use_bias=False, name='P_a')

    if encoder.attn_filters:
        filter_shape = [encoder.attn_filter_length * 2 + 1, 1, 1, encoder.attn_filters]
        filter_ = get_variable('filter', filter_shape)
        prev_weights = tf.reshape(prev_weights, tf.stack([batch_size, time_steps, 1, 1]))
        conv = tf.nn.conv2d(prev_weights, filter_, [1, 1, 1, 1], 'SAME')
        conv = tf.squeeze(conv, axis=2)
        
        y += dense(conv, encoder.attn_size, use_bias=False, name='C_a')

    v = get_variable('v_a', [encoder.attn_size])
    return tf.reduce_sum(v * tf.tanh(y), axis=2)
