import tensorflow as tf

                    use_spectral_norm,
                    is_training,
                    None,
                    conv_dims=2)

        def hw_flatten(x):
            return tf.reshape(x, shape=[x.shape[0], -1, x.shape[-1]])

        # N = h * w
        s = tf.matmul(hw_flatten(g), hw_flatten(f), transpose_b=True)  # # [bs, N, N]

        beta = tf.nn.softmax(s, axis=-1)  # attention map
