Dice loss comes from image segmentation, where most pixels are background and a plain per-pixel loss barely notices the small foreground region. It instead measures the overlap between the predicted and true masks directly.
Task: write dice_loss(y_true, y_pred, smooth) returning 1 - Dice, rounded to 4 decimal places.
y_true and y_pred are flat lists of values in [0, 1] — a mask and a prediction, one value per pixel.smooth keeps the loss defined even when both masks are entirely empty; without it that case would divide by zero.