import tensorflow as tf

        elif encoder.attn_norm_fun == 'sigmoid':
            weights = tf.nn.sigmoid(e)
        elif encoder.attn_norm_fun == 'max':
            weights = tf.one_hot(tf.argmax(e, -1), depth=tf.shape(e)[1])
        else:
            e -= tf.reduce_max(e, axis=1, keep_dims=True)
            T = encoder.attn_temperature or 1.0
            exp = tf.exp(e / T) * mask
            weights = exp / tf.reduce_sum(exp, axis=-1, keep_dims=True)

        weighted_average = tf.reduce_sum(tf.expand_dims(weights, 2) * hidden_states, axis=1)

        return weighted_average, weights


def no_attention(state, hidden_states, *args, **kwargs):
