import tensorflow as tf


            if encoder.attn_window_size > 0:
                sigma = encoder.attn_window_size / 2
                numerator = -tf.pow((idx - pos), tf.convert_to_tensor(2, dtype=tf.float32))
                div = tf.truediv(numerator, 2 * sigma ** 2)

                weights *= tf.exp(div)  # result of the truncated normal distribution
                # normalize to keep a probability distribution
