code: def ssim(self, img1: torch.Tensor, img2: torch.Tensor):
      n_dim = len(img1.shape) - 2
      padd = int(self.window_size / 2)
  
      if n_dim == 2:
          (_, channel, height, width) = img1.size()
          convFunction = F.conv2d
      elif n_dim == 3:
          (_, channel, height, width, depth) = img1.size()
          convFunction = F.conv3d
  
      window = self._create_window(n_dim=n_dim, channel=channel).to(
          img1.device
      )
  
      mu1 = convFunction(img1, window, padding=padd, groups=channel)
      mu2 = convFunction(img2, window, padding=padd, groups=channel)
  
      mu1_sq = mu1.pow(2)
      mu2_sq = mu2.pow(2)
      mu1_mu2 = mu1 * mu2
  
      sigma1_sq = (
          convFunction(
              img1 * img1, window, padding=padd, groups=channel
          )
          - mu1_sq
      )
      sigma2_sq = (
          convFunction(
              img2 * img2, window, padding=padd, groups=channel
          )
          - mu2_sq
      )
      sigma12 = (
          convFunction(
              img1 * img2, window, padding=padd, groups=channel
          )
          - mu1_mu2
      )
  
      L = 1  # data already in [0, 1]
      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
      )
  
      ret = ssim_map.mean()
      return ret, cs
  
file_path: benchmark_VAE/src/pythae/models/msssim_vae/msssim_vae_utils.py
imports: import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 4 for calling the MSSSIM obj's underlying member method code with example usage: obj.ssim(img1, img2) and returns: ret,  cs