class_docstr: Compute the generalized Wasserstein Dice Loss defined in:
  
      Fidon L. et al. (2017) Generalised Wasserstein Dice Score for Imbalanced Multi-class
      Segmentation using Holistic Convolutional Networks. BrainLes 2017.
  
  Or its variant (use the option weighting_mode="GDL") defined in the Appendix of:
  
      Tilborghs, S. et al. (2020) Comparative study of deep learning methods for the automatic
      segmentation of lung, lesion and lesion type in CT scans of COVID-19 patients.
      arXiv preprint arXiv:2007.15546
  
  Adapted from:
      https://github.com/LucasFidon/GeneralizedWassersteinDiceLoss
class_docstr_tok: ["Compute","the","generalized","Wasserstein","Dice","Loss","defined","in",":","Fidon","L.","et","al",".","(","2017",")","Generalised","Wasserstein","Dice","Score","for","Imbalanced","Multi-class","Segmentation","using","Holistic","Convolutional","Networks",".","BrainLes","2017",".","Or","its","variant","(","use","the","option","weighting_mode=","''","GDL","''",")","defined","in","the","Appendix","of",":","Tilborghs",",","S.","et","al",".","(","2020",")","Comparative","study","of","deep","learning","methods","for","the","automatic","segmentation","of","lung",",","lesion","and","lesion","type","in","CT","scans","of","COVID-19","patients",".","arXiv","preprint","arXiv:2007.15546","Adapted","from",":","https",":","\/\/github.com\/LucasFidon\/GeneralizedWassersteinDiceLoss"]
docstr: Args:
      alpha: generalised number of true positives of target class.
      flat_target: the target tensor.
      wasserstein_distance_map: the map obtained from the above function.
docstr_tok: ["Args",":","alpha",":","generalised","number","of","true","positives","of","target","class",".","flat_target",":","the","target","tensor",".","wasserstein_distance_map",":","the","map","obtained","from","the","above","function","."]
code: def _compute_generalized_true_positive(
      self,
      alpha: torch.Tensor,
      flat_target: torch.Tensor,
      wasserstein_distance_map: torch.Tensor,
  ) -> torch.Tensor:
      """
      Args:
          alpha: generalised number of true positives of target class.
          flat_target: the target tensor.
          wasserstein_distance_map: the map obtained from the above function.
      """
      # Extend alpha to a map and select value at each voxel according to flat_target
      alpha_extended = torch.unsqueeze(alpha, dim=2)
      alpha_extended = alpha_extended.expand(
          (flat_target.size(0), self.num_classes, flat_target.size(1))
      )
      flat_target_extended = torch.unsqueeze(flat_target, dim=1)
      alpha_extended = torch.gather(
          alpha_extended, index=flat_target_extended, dim=1
      )
  
      return torch.sum(
          alpha_extended * (1.0 - wasserstein_distance_map), dim=[1, 2]
      )
  
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 4 for calling the GeneralizedWassersteinDiceLoss obj's underlying member method code with example usage: obj._compute_generalized_true_positive(alpha, flat_target, wasserstein_distance_map) and returns: torch