docstr: We want to make sure that the adversarial losses do what they should.
  If the discriminator takes in a tensor that looks positive, yet the label is fake,
  the loss should be bigger than that obtained with a tensor that looks negative.
  Same for the real label, and for the generator.
docstr_tok: ["We","want","to","make","sure","that","the","adversarial","losses","do","what","they","should",".","If","the","discriminator","takes","in","a","tensor","that","looks","positive",",","yet","the","label","is","fake",",","the","loss","should","be","bigger","than","that","obtained","with","a","tensor","that","looks","negative",".","Same","for","the","real","label",",","and","for","the","generator","."]
code: def test_loss_logic(self, input_param: dict, shape_input: list):
      """
      We want to make sure that the adversarial losses do what they should.
      If the discriminator takes in a tensor that looks positive, yet the label is fake,
      the loss should be bigger than that obtained with a tensor that looks negative.
      Same for the real label, and for the generator.
      """
      loss = PatchAdversarialLoss(**input_param)
      fakes = self.get_input(shape_input, is_positive=False)
      reals = self.get_input(shape_input, is_positive=True)
      # Discriminator: fake label
      loss_disc_f_f = loss(
          fakes, target_is_real=False, for_discriminator=True
      )
      loss_disc_f_r = loss(
          reals, target_is_real=False, for_discriminator=True
      )
      assert loss_disc_f_f < loss_disc_f_r
      # Discriminator: real label
      loss_disc_r_f = loss(
          fakes, target_is_real=True, for_discriminator=True
      )
      loss_disc_r_r = loss(
          reals, target_is_real=True, for_discriminator=True
      )
      assert loss_disc_r_f > loss_disc_r_r
      # Generator:
      loss_gen_f = loss(
          fakes, target_is_real=True, for_discriminator=False
      )  # target_is_real is overridden
      loss_gen_r = loss(
          reals, target_is_real=True, for_discriminator=False
      )  # target_is_real is overridden
      assert loss_gen_f > loss_gen_r
  
file_path: MONAI/tests/test_adversarial_loss.py
imports: from __future__ import annotations
  import unittest
  import torch
  from parameterized import parameterized
  from monai.losses import PatchAdversarialLoss
label_desc: Use image node_id 3 for calling the TestPatchAdversarialLoss obj's underlying member method code with example usage: obj.test_loss_logic(input_param, shape_input) without return types