I think, I found the bug:
        _, _, H, W = A.shape
        mask2 = tr.div(mask2*H*W, 2*tr.norm(mask2, p=1))

Here I calculate the norm overall what is wrong!
I’ll try to correct this – calculate the norm of the mask for each batch…