This was the problem! Now working with this:
        B, _, H, W = A.shape
        norm =  2*tr.norm(mask1, p=1, dim=(1,2,3))
        norm = norm.reshape(B, 1, 1, 1)
        mask1 = tr.div(mask1*H*W, norm)

Thank you for your help!