class_docstr: modified from https://github.com/jorge-pessoa/pytorch-msssim
class_docstr_tok: ["modified","from","https",":","\/\/github.com\/jorge-pessoa\/pytorch-msssim"]
docstr: args:
      y_true : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
      y_pred : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
      w_size : int, default 11
      size_average : boolean, default True
      full : boolean, default False
  return ssim, larger the better
docstr_tok: ["args",":","y_true",":","4-d","ndarray","in","[","batch_size",",","channels",",","img_rows",",","img_cols","]","y_pred",":","4-d","ndarray","in","[","batch_size",",","channels",",","img_rows",",","img_cols","]","w_size",":","int",",","default","11","size_average",":","boolean",",","default","True","full",":","boolean",",","default","False","return","ssim",",","larger","the","better"]
code: def __call__(
      self, y_pred, y_true, w_size=11, size_average=True, full=False
  ):
      """
      args:
          y_true : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
          y_pred : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
          w_size : int, default 11
          size_average : boolean, default True
          full : boolean, default False
      return ssim, larger the better
      """
      # Value range can be different from 255. Other common ranges are 1 (sigmoid) and 2 (tanh).
      if torch.max(y_pred) > 128:
          max_val = 255
      else:
          max_val = 1
  
      if torch.min(y_pred) < -0.5:
          min_val = -1
      else:
          min_val = 0
      L = max_val - min_val
  
      padd = 0
      (_, channel, height, width) = y_pred.size()
      window = self.create_window(w_size, channel=channel).to(
          y_pred.device
      )
  
      mu1 = F.conv2d(y_pred, window, padding=padd, groups=channel)
      mu2 = F.conv2d(y_true, window, padding=padd, groups=channel)
  
      mu1_sq = mu1.pow(2)
      mu2_sq = mu2.pow(2)
      mu1_mu2 = mu1 * mu2
  
      sigma1_sq = (
          F.conv2d(
              y_pred * y_pred, window, padding=padd, groups=channel
          )
          - mu1_sq
      )
      sigma2_sq = (
          F.conv2d(
              y_true * y_true, window, padding=padd, groups=channel
          )
          - mu2_sq
      )
      sigma12 = (
          F.conv2d(
              y_pred * y_true, window, padding=padd, groups=channel
          )
          - mu1_mu2
      )
  
      C1 = (0.01 * L) ** 2
      C2 = (0.03 * L) ** 2
  
      v1 = 2.0 * sigma12 + C2
      v2 = sigma1_sq + sigma2_sq + C2
      cs = torch.mean(v1 / v2)  # contrast sensitivity
  
      ssim_map = ((2 * mu1_mu2 + C1) * v1) / (
          (mu1_sq + mu2_sq + C1) * v2
      )
  
      if size_average:
          ret = ssim_map.mean()
      else:
          ret = ssim_map.mean(1).mean(1).mean(1)
  
      if full:
          return ret, cs
      return ret
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 5 for calling the SSIM obj's underlying member method code with example usage: obj.__call__(y_pred, y_true, w_size, size_average, full) and returns: ret, ret,  cs