import tensorflow as tf

        # data for pooling
        pooling_data = tf.tile(tf.expand_dims(rep_dep_tensor, 1), [1, sl_unhead, 1, 1])  # bs,sluh,sld,hn
        # execute mean pooling based on pooling_mask[bs, sluh, sld] and pooling_data[bs,sluh,sld,hn]
        pooling_data = mask_for_high_rank(pooling_data, pooling_mask)  # [bs,sluh,sld,hn]
        pooling_data_sum = tf.reduce_sum(pooling_data, -2)  # [bs,sluh,hn]
        pooling_den = tf.reduce_sum(tf.cast(pooling_mask, tf.int32), -1, keep_dims=True)  # [bs,sluh]
        pooling_den = tf.where(tf.equal(pooling_den, 0), tf.ones_like(pooling_den), pooling_den)

        pooling_result = pooling_data_sum / tf.cast(pooling_den, tf.float32)
        return pooling_result


