class_docstr: SSimLoss.
  
  This is an implementation of structural similarity (SSIM) loss.
  This code is modified from https://github.com/Po-Hsun-Su/pytorch-ssim.
class_docstr_tok: ["SSimLoss",".","This","is","an","implementation","of","structural","similarity","(","SSIM",")","loss",".","This","code","is","modified","from","https",":","\/\/github.com\/Po-Hsun-Su\/pytorch-ssim","."]
docstr: Calculate forward propagation.
  
  Args:
      outputs (torch.Tensor): Batch of output sequences generated
          by the model (batch, time, mels).
      target (torch.Tensor): Batch of sequences with true
          states (batch, time, mels).
  
  Returns:
      Tensor: Loss scalar value.
docstr_tok: ["Calculate","forward","propagation",".","Args",":","outputs","(","torch.Tensor",")",":","Batch","of","output","sequences","generated","by","the","model","(","batch",",","time",",","mels",")",".","target","(","torch.Tensor",")",":","Batch","of","sequences","with","true","states","(","batch",",","time",",","mels",")",".","Returns",":","Tensor",":","Loss","scalar","value","."]
code: def forward(self, outputs: torch.Tensor, target: torch.Tensor):
      """Calculate forward propagation.
  
      Args:
          outputs (torch.Tensor): Batch of output sequences generated
              by the model (batch, time, mels).
          target (torch.Tensor): Batch of sequences with true
              states (batch, time, mels).
  
      Returns:
          Tensor: Loss scalar value.
  
      """
      with torch.no_grad():
          dim = target.size(-1)
          mask = (
              target.abs()
              .sum(-1, keepdim=True)
              .ne(0)
              .float()
              .repeat(1, 1, dim)
          )
      outputs = outputs.unsqueeze(1) + self.bias
      target = target.unsqueeze(1) + self.bias
      loss = 1 - self.ssim(outputs, target)
      loss = (loss * mask).sum() / mask.sum()
      return loss
  
file_path: espnet/espnet2/tts/prodiff/loss.py
imports: from math import exp
  from typing import Tuple
  import torch
  from torch.nn import functional
  from typeguard import check_argument_types
  from espnet.nets.pytorch_backend.fastspeech.duration_predictor import DurationPredictorLoss
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
label_desc: Use image node_id 2 for calling the SSimLoss obj's underlying member method code with example usage: obj.forward(outputs, target) and returns: loss