class_docstr: SSIM loss as explained here https://en.wikipedia.org/wiki/Structural_similarity
docstr: Args:
      y_hat (tensor): model prediction values.
      y (tensor): target values.
      length (tensor): length of each sample in a batch.
  Shapes:
      y_hat: B x T X D
      y: B x T x D
      length: B
   Returns:
      loss: An average loss value in range [0, 1] masked by the length.
docstr_tok: ["Args",":","y_hat","(","tensor",")",":","model","prediction","values",".","y","(","tensor",")",":","target","values",".","length","(","tensor",")",":","length","of","each","sample","in","a","batch",".","Shapes",":","y_hat",":","B","x","T","X","D","y",":","B","x","T","x","D","length",":","B","Returns",":","loss",":","An","average","loss","value","in","range","[","0",",","1","]","masked","by","the","length","."]
code: def forward(self, y_hat, y, length=None):
      """
      Args:
          y_hat (tensor): model prediction values.
          y (tensor): target values.
          length (tensor): length of each sample in a batch.
      Shapes:
          y_hat: B x T X D
          y: B x T x D
          length: B
       Returns:
          loss: An average loss value in range [0, 1] masked by the length.
      """
      if length is not None:
          m = (
              sequence_mask(sequence_length=length, max_len=y.size(1))
              .unsqueeze(2)
              .float()
              .to(y_hat.device)
          )
          y_hat, y = y_hat * m, y * m
      return 1 - self.loss_func(y_hat.unsqueeze(1), y.unsqueeze(1))
  
imports: import math
  import numpy
  import torch
  from torch import nn
  from inspect import signature
  from torch.nn import functional
  from TTS.tts.utils.generic_utils import sequence_mask
  from TTS.tts.utils.ssim import ssim
label_desc: Use image node_id 2 for calling the SSIMLoss obj's underlying member method code with example usage: obj.forward(y_hat, y, length) and returns: unknown