import torch


def pixelwise_adversarial_loss(probs, mask):
    """Compute pixelwise adversarial loss for a masked image
    given the pixel mask.
    Note:
        Assumes the mask is generated by use of the CutMix method.
    Note (2):
        This is exactly the same as the normal adversarial_loss(., .)
        (because of reduction). The reason why this is defined is that 
        it makes the idea more clear.

    Args:
        probs: Pixel-wise real/fake predictions. Assumes real := 1, fake := 0 
               Has shape (N, C, H, W)
        mask: Mask, with real := 1, fake (cutmixed) := 0
               Has shape (N, C, H, W) (same as predictions)
    """
    return torch.nn.BCEWithLogitsLoss()(probs, mask)