class_docstr: AsymmetricFocalTverskyLoss is a variant of FocalTverskyLoss, which attentions to the foreground class.
  
  Actually, it's only supported for binary image segmentation now.
  
  Reimplementation of the Asymmetric Focal Tversky Loss described in:
  
  - "Unified Focal Loss: Generalising Dice and Cross Entropy-based Losses to Handle Class Imbalanced Medical Image Segmentation",
  Michael Yeung, Computerized Medical Imaging and Graphics
class_docstr_tok: ["AsymmetricFocalTverskyLoss","is","a","variant","of","FocalTverskyLoss",",","which","attentions","to","the","foreground","class",".","Actually",",","it","'s","only","supported","for","binary","image","segmentation","now",".","Reimplementation","of","the","Asymmetric","Focal","Tversky","Loss","described","in",":","-","``","Unified","Focal","Loss",":","Generalising","Dice","and","Cross","Entropy-based","Losses","to","Handle","Class","Imbalanced","Medical","Image","Segmentation","''",",","Michael","Yeung",",","Computerized","Medical","Imaging","and","Graphics"]
code: def forward(
      self, y_pred: torch.Tensor, y_true: torch.Tensor
  ) -> torch.Tensor:
      n_pred_ch = y_pred.shape[1]
  
      if self.to_onehot_y:
          if n_pred_ch == 1:
              warnings.warn(
                  "single channel prediction, `to_onehot_y=True` ignored."
              )
          else:
              y_true = one_hot(y_true, num_classes=n_pred_ch)
  
      if y_true.shape != y_pred.shape:
          raise ValueError(
              f"ground truth has different shape ({y_true.shape}) from input ({y_pred.shape})"
          )
  
      # clip the prediction to avoid NaN
      y_pred = torch.clamp(y_pred, self.epsilon, 1.0 - self.epsilon)
      axis = list(range(2, len(y_pred.shape)))
  
      # Calculate true positives (tp), false negatives (fn) and false positives (fp)
      tp = torch.sum(y_true * y_pred, dim=axis)
      fn = torch.sum(y_true * (1 - y_pred), dim=axis)
      fp = torch.sum((1 - y_true) * y_pred, dim=axis)
      dice_class = (tp + self.epsilon) / (
          tp + self.delta * fn + (1 - self.delta) * fp + self.epsilon
      )
  
      # Calculate losses separately for each class, enhancing both classes
      back_dice = 1 - dice_class[:, 0]
      fore_dice = (1 - dice_class[:, 1]) * torch.pow(
          1 - dice_class[:, 1], -self.gamma
      )
  
      # Average class scores
      loss = torch.mean(torch.stack([back_dice, fore_dice], dim=-1))
      return loss
  
file_path: MONAI/monai/losses/unified_focal_loss.py
imports: from __future__ import annotations
  import warnings
  import torch
  from torch.nn.modules.loss import _Loss
  from monai.networks import one_hot
  from monai.utils import LossReduction
label_desc: Use image node_id 2 for calling the AsymmetricFocalTverskyLoss obj's underlying member method code with example usage: obj.forward(y_pred, y_true) and returns: loss