class_docstr: Compute both Dice loss and Focal Loss, and return the weighted sum of these two losses.
  The details of Dice loss is shown in ``monai.losses.DiceLoss``.
  The details of Focal Loss is shown in ``monai.losses.FocalLoss``.
  
  ``gamma`` and ``lambda_focal`` are only used for the focal loss.
  ``include_background``, ``weight`` and ``reduction`` are used for both losses
  and other parameters are only used for dice loss.
class_docstr_tok: ["Compute","both","Dice","loss","and","Focal","Loss",",","and","return","the","weighted","sum","of","these","two","losses",".","The","details","of","Dice","loss","is","shown","in","``","monai.losses.DiceLoss","``",".","The","details","of","Focal","Loss","is","shown","in","``","monai.losses.FocalLoss","``",".","``","gamma","``","and","``","lambda_focal","``","are","only","used","for","the","focal","loss",".","``","include_background","``",",","``","weight","``","and","``","reduction","``","are","used","for","both","losses","and","other","parameters","are","only","used","for","dice","loss","."]
docstr: Args:
      input: the shape should be BNH[WD]. The input should be the original logits
          due to the restriction of ``monai.losses.FocalLoss``.
      target: the shape should be BNH[WD] or B1H[WD].
  
  Raises:
      ValueError: When number of dimensions for input and target are different.
      ValueError: When number of channels for target is neither 1 nor the same as input.
docstr_tok: ["Args",":","input",":","the","shape","should","be","BNH","[","WD","]",".","The","input","should","be","the","original","logits","due","to","the","restriction","of","``","monai.losses.FocalLoss","``",".","target",":","the","shape","should","be","BNH","[","WD","]","or","B1H","[","WD","]",".","Raises",":","ValueError",":","When","number","of","dimensions","for","input","and","target","are","different",".","ValueError",":","When","number","of","channels","for","target","is","neither","1","nor","the","same","as","input","."]
code: def forward(
      self, input: torch.Tensor, target: torch.Tensor
  ) -> torch.Tensor:
      """
      Args:
          input: the shape should be BNH[WD]. The input should be the original logits
              due to the restriction of ``monai.losses.FocalLoss``.
          target: the shape should be BNH[WD] or B1H[WD].
  
      Raises:
          ValueError: When number of dimensions for input and target are different.
          ValueError: When number of channels for target is neither 1 nor the same as input.
  
      """
      if len(input.shape) != len(target.shape):
          raise ValueError(
              "the number of dimensions for input and target should be the same, "
              f"got shape {input.shape} and {target.shape}."
          )
      if self.to_onehot_y:
          n_pred_ch = input.shape[1]
          if n_pred_ch == 1:
              warnings.warn(
                  "single channel prediction, `to_onehot_y=True` ignored."
              )
          else:
              target = one_hot(target, num_classes=n_pred_ch)
      dice_loss = self.dice(input, target)
      focal_loss = self.focal(input, target)
      total_loss: torch.Tensor = (
          self.lambda_dice * dice_loss + self.lambda_focal * focal_loss
      )
      return total_loss
  
imports: from __future__ import annotations
  import warnings
  from collections.abc import Callable, Sequence
  from typing import Any
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.loss import _Loss
  from monai.losses.focal_loss import FocalLoss
  from monai.losses.spatial_mask import MaskedLoss
  from monai.networks import one_hot
  from monai.utils import DiceCEReduction, LossReduction, Weight, deprecated_arg, look_up_option, pytorch_after
label_desc: Use image node_id 2 for calling the DiceFocalLoss obj's underlying member method code with example usage: obj.forward(input, target) and returns: total_loss