oh i see now why you said it’s an approximation.
But in order to compare with my target values, I need values either 0 or 1 (I think). So, do you think whether rounding after  scores.softmax(dim=1)[:, 1] is a correct way of doing it?
For example,
pred = scores.softmax(dim=1)[:, 1]
pred = torch.round(pred)
dice_loss(pred,target)

def dice_loss(pred,target):
    with torch.enable_grad():
        numerator = 2 * torch.sum(pred * target)
        denominator = torch.sum(pred + target)
        return 1 - torch.true_divide((numerator + 1), (denominator + 1))