code: def ssim(img1, img2):
      C1 = (0.01 * 255) ** 2
      C2 = (0.03 * 255) ** 2
  
      img1 = img1.astype(np.float64)
      img2 = img2.astype(np.float64)
      kernel = cv2.getGaussianKernel(11, 1.5)
      window = np.outer(kernel, kernel.transpose())
  
      mu1 = cv2.filter2D(img1, -1, window)[5:-5, 5:-5]  # valid
      mu2 = cv2.filter2D(img2, -1, window)[5:-5, 5:-5]
      mu1_sq = mu1**2
      mu2_sq = mu2**2
      mu1_mu2 = mu1 * mu2
      sigma1_sq = (
          cv2.filter2D(img1**2, -1, window)[5:-5, 5:-5] - mu1_sq
      )
      sigma2_sq = (
          cv2.filter2D(img2**2, -1, window)[5:-5, 5:-5] - mu2_sq
      )
      sigma12 = (
          cv2.filter2D(img1 * img2, -1, window)[5:-5, 5:-5] - mu1_mu2
      )
  
      ssim_map = ((2 * mu1_mu2 + C1) * (2 * sigma12 + C2)) / (
          (mu1_sq + mu2_sq + C1) * (sigma1_sq + sigma2_sq + C2)
      )
      return ssim_map.mean()
  
imports: import math
  import os
  import random
  from datetime import datetime
  import cv2
  import numpy
  import torch
  from torchvision.utils import make_grid
label_desc: Use image node_id 45 for calling a global function with example usage: ssim(img1, img2) and returns: ssim_map