code: def soft_dice(
      y_true: torch.Tensor, y_pred: torch.Tensor, smooth: float = 1.0
  ) -> torch.Tensor:
      """
      Function to compute soft dice loss
  
      Adapted from:
          https://github.com/jocpae/clDice/blob/master/cldice_loss/pytorch/cldice.py#L22
  
      Args:
          y_true: the shape should be BCH(WD)
          y_pred: the shape should be BCH(WD)
  
      Returns:
          dice loss
      """
      intersection = torch.sum((y_true * y_pred)[:, 1:, ...])
      coeff = (2.0 * intersection + smooth) / (
          torch.sum(y_true[:, 1:, ...])
          + torch.sum(y_pred[:, 1:, ...])
          + smooth
      )
      soft_dice: torch.Tensor = 1.0 - coeff
      return soft_dice
  
file_path: MONAI/monai/losses/cldice.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch.nn.modules.loss import _Loss
label_desc: Use image node_id 5 for calling a global function with example usage: soft_dice(y_true, y_pred, smooth) and returns: soft_dice