class_docstr: Calculates an adversarial loss on a Patch Discriminator or a Multi-scale Patch Discriminator.
  Warning: due to the possibility of using different criterions, the output of the discrimination
  mustn't be passed to a final activation layer. That is taken care of internally within the loss.
  
  Args:
      reduction: {``"none"``, ``"mean"``, ``"sum"``}
          Specifies the reduction to apply to the output. Defaults to ``"mean"``.
  
          - ``"none"``: no reduction will be applied.
          - ``"mean"``: the sum of the output will be divided by the number of elements in the output.
          - ``"sum"``: the output will be summed.
  
      criterion: which criterion (hinge, least_squares or bce) you want to use on the discriminators outputs.
          Depending on the criterion, a different activation layer will be used. Make sure you don't run the outputs
          through an activation layer prior to calling the loss.
      no_activation_leastsq: if True, the activation layer in the case of least-squares is removed.
code: def __init__(
      self,
      reduction: LossReduction | str = LossReduction.MEAN,
      criterion: str = AdversarialCriterions.LEAST_SQUARE,
      no_activation_leastsq: bool = False,
  ) -> None:
      super().__init__(reduction=LossReduction(reduction))
  
      if criterion.lower() not in list(AdversarialCriterions):
          raise ValueError(
              "Unrecognised criterion entered for Adversarial Loss. Must be one in: %s"
              % ", ".join(AdversarialCriterions)
          )
  
      # Depending on the criterion, a different activation layer is used.
      self.real_label = 1.0
      self.fake_label = 0.0
      self.loss_fct: _Loss
      if criterion == AdversarialCriterions.BCE:
          self.activation = get_act_layer("SIGMOID")
          self.loss_fct = torch.nn.BCELoss(reduction=reduction)
      elif criterion == AdversarialCriterions.HINGE:
          self.activation = get_act_layer("TANH")
          self.fake_label = -1.0
      elif criterion == AdversarialCriterions.LEAST_SQUARE:
          if no_activation_leastsq:
              self.activation = None
          else:
              self.activation = get_act_layer(
                  name=("LEAKYRELU", {"negative_slope": 0.05})
              )
          self.loss_fct = torch.nn.MSELoss(reduction=reduction)
  
      self.criterion = criterion
      self.reduction = reduction
  
file_path: MONAI/monai/losses/adversarial_loss.py
imports: from __future__ import annotations
  import warnings
  import torch
  from torch.nn.modules.loss import _Loss
  from monai.networks.layers.utils import get_act_layer
  from monai.utils import LossReduction
  from monai.utils.enums import StrEnum
label_desc: Use image node_id 1 to create a new PatchAdversarialLoss object from inherited base classes: _Loss with example: obj = PatchAdversarialLoss(reduction, criterion, no_activation_leastsq)