import torch


def texture_loss(img_pred, img_gt, mask_gt):
    """
    Input:
      img_pred, img_gt: B x 3 x H x W
      mask_pred, mask_gt: B x H x W
    """
    mask_gt = mask_gt.unsqueeze(1)

    return torch.nn.L1Loss()(img_pred * mask_gt, img_gt * mask_gt)