class_docstr: gradient penalty for UASR.
class_docstr_tok: ["gradient","penalty","for","UASR","."]
code: def __init__(
      self,
      discriminator: AbsDiscriminator,
      weight: float = 1.0,
      probabilistic_grad_penalty_slicing: str2bool = False,
      reduction: str = "sum",
  ):
      super().__init__()
      assert check_argument_types()
  
      self.discriminator = [discriminator]
      self.weight = weight
      self.probabilistic_grad_penalty_slicing = (
          probabilistic_grad_penalty_slicing
      )
      self.reduction = reduction
  
file_path: espnet/espnet2/uasr/loss/gradient_penalty.py
imports: import numpy
  import torch
  from torch import autograd
  from typeguard import check_argument_types
  from espnet2.uasr.discriminator.abs_discriminator import AbsDiscriminator
  from espnet2.uasr.loss.abs_loss import AbsUASRLoss
  from espnet2.utils.types import str2bool
label_desc: Use image node_id 1 to create a new UASRGradientPenalty object from inherited base classes: AbsUASRLoss with example: obj = UASRGradientPenalty(discriminator, weight, probabilistic_grad_penalty_slicing, reduction)