import torch


def dice_loss(y_pred, y_true):
    numerator = 2 * torch.sum(y_true * y_pred)
    denomiator = torch.sum(y_true + y_pred)
    return 1 - (numerator + 1) / (denomiator + 1)

758fb15c511c81f50ca0cd161dd08399cdc37bc4
<mask token>

<mask token>


def dice_loss(y_pred, y_true):
    numerator = 2 * torch.sum(y_true * y_pred)
    denomiator = torch.sum(y_true + y_pred)
    return 1 - (numerator + 1) / (denomiator + 1)

import torch


def dice_loss(y_pred, y_true):
    numerator = 2 * torch.sum(y_true * y_pred)
    denomiator = torch.sum(y_true + y_pred)
    return 1 - (numerator + 1) / (denomiator + 1)
