import tensorflow as tf

    averages_op = averages.apply(ops)

    for op in ops:
        tf.scalar_summary(scope_pfix + op.name + raw_pfix, op)
        tf.scalar_summary(scope_pfix + op.name + avg_pfix,
                          averages.average(op))

    with tf.control_dependencies([averages_op]):
        for i, dep_op in enumerate(dep_ops):
            dep_ops[i] = tf.identity(dep_op, name=dep_op.name.split(':')[0])

    return dep_ops

def exp_average(vec, curr_avg, decay=0.9):
    vec_avg = tf.reduce_mean(vec, 0)
    avg = tf.assign(curr_avg, curr_avg * decay + vec_avg * (1-decay))
    return avg

def gather_vec_pairs(vecs, gather_inds):
    """
    gather obj-subj feature pairs
    """
    vec_pairs = tf.gather(vecs, gather_inds)
    vec_len = int(vec_pairs.get_shape()[2]) * 2
    vec_pairs = tf.reshape(vec_pairs, [-1, vec_len])
    return vec_pairs

def pad_and_gather(vecs, mask_inds, pad=None):
