import torch


def calculate_dice(pred_vol: torch.Tensor, gt_vol: torch.Tensor) -> torch.Tensor:
    """
        Cacluate Dice Score
    :param pred_vol: Predicted volume, shape: [B, N_VOX (32), N_VOX (32), N_VOX (32)]
    :param gt_vol: Ground-truth volume, shape: [B, N_VOX (32), N_VOX (32), N_VOX (32)]
    :return: Dice Score, scalar
    """
    dims = [1, 2, 3]
    intersection = torch.sum(pred_vol * gt_vol, dim=dims).float()
    union = torch.sum(pred_vol, dim=dims) + torch.sum(gt_vol, dim=dims)
    return torch.mean((2. * intersection) / union)