class_docstr: Compute the generalised Dice loss defined in:
  
      Sudre, C. et. al. (2017) Generalised Dice overlap as a deep learning
      loss function for highly unbalanced segmentations. DLMIA 2017.
  
  Adapted from:
      https://github.com/NifTK/NiftyNet/blob/v0.6.0/niftynet/layer/loss_segmentation.py#L279
class_docstr_tok: ["Compute","the","generalised","Dice","loss","defined","in",":","Sudre",",","C.","et",".","al",".","(","2017",")","Generalised","Dice","overlap","as","a","deep","learning","loss","function","for","highly","unbalanced","segmentations",".","DLMIA","2017",".","Adapted","from",":","https",":","\/\/github.com\/NifTK\/NiftyNet\/blob\/v0.6.0\/niftynet\/layer\/loss_segmentation.py","#","L279"]
code: def w_func(self, grnd):
      if self.w_type == str(Weight.SIMPLE):
          return torch.reciprocal(grnd)
      if self.w_type == str(Weight.SQUARE):
          return torch.reciprocal(grnd * grnd)
      return torch.ones_like(grnd)
  
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 GeneralizedDiceLoss obj's underlying member method code with example usage: obj.w_func(grnd) and returns: torch, torch, torch