class_docstr: smoothness penalty for UASR.
docstr: Forward.
  
  Args:
      dense_logits: output logits of generator
      dense_padding_mask: padding mask of logits
      sample_size: batch size
      is_discriminative_step: Whether is training discriminator
docstr_tok: ["Forward",".","Args",":","dense_logits",":","output","logits","of","generator","dense_padding_mask",":","padding","mask","of","logits","sample_size",":","batch","size","is_discriminative_step",":","Whether","is","training","discriminator"]
code: def forward(
      self,
      dense_logits: torch.Tensor,
      dense_padding_mask: torch.Tensor,
      sample_size: int,
      is_discriminative_step: bool,
  ):
      """Forward.
  
      Args:
          dense_logits: output logits of generator
          dense_padding_mask: padding mask of logits
          sample_size: batch size
          is_discriminative_step: Whether is training discriminator
      """
      if self.weight > 0 and not is_discriminative_step:
          smoothness_penalty = F.mse_loss(
              dense_logits[:, :-1],
              dense_logits[:, 1:],
              reduction=self.reduction,
          )
          smoothness_penalty[dense_padding_mask[:, 1:]] = 0
          smoothness_penalty = smoothness_penalty.mean() * sample_size
  
          return smoothness_penalty
      else:
          return 0
  
imports: import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.uasr.loss.abs_loss import AbsUASRLoss
label_desc: Use image node_id 2 for calling the UASRSmoothnessPenalty obj's underlying member method code with example usage: obj.forward(dense_logits, dense_padding_mask, sample_size, is_discriminative_step) and returns: smoothness_penalty, int