code: def _skimage_ssim(
      preds,
      target,
      data_range,
      sigma,
      kernel_size=None,
      return_ssim_image=False,
      gaussian_weights=True,
      reduction_arg="elementwise_mean",
  ):
      if isinstance(data_range, tuple):
          preds = preds.clamp(min=data_range[0], max=data_range[1])
          target = target.clamp(min=data_range[0], max=data_range[1])
          data_range = data_range[1] - data_range[0]
      if len(preds.shape) == 4:
          c, h, w = preds.shape[-3:]
          sk_preds = preds.view(-1, c, h, w).permute(0, 2, 3, 1).numpy()
          sk_target = (
              target.view(-1, c, h, w).permute(0, 2, 3, 1).numpy()
          )
      elif len(preds.shape) == 5:
          c, d, h, w = preds.shape[-4:]
          sk_preds = (
              preds.view(-1, c, d, h, w).permute(0, 2, 3, 4, 1).numpy()
          )
          sk_target = (
              target.view(-1, c, d, h, w).permute(0, 2, 3, 4, 1).numpy()
          )
  
      results = torch.zeros(sk_preds.shape[0], dtype=target.dtype)
      if not return_ssim_image:
          for i in range(sk_preds.shape[0]):
              res = structural_similarity(
                  sk_target[i],
                  sk_preds[i],
                  data_range=data_range,
                  multichannel=True,
                  gaussian_weights=gaussian_weights,
                  win_size=kernel_size,
                  sigma=sigma,
                  use_sample_covariance=False,
                  full=return_ssim_image,
                  channel_axis=-1,
              )
              results[i] = torch.from_numpy(np.asarray(res)).type(
                  preds.dtype
              )
          return results if reduction_arg != "sum" else results.sum()
  
      fullimages = torch.zeros(target.shape, dtype=target.dtype)
      for i in range(sk_preds.shape[0]):
          res, fullimage = structural_similarity(
              sk_target[i],
              sk_preds[i],
              data_range=data_range,
              multichannel=True,
              gaussian_weights=gaussian_weights,
              win_size=kernel_size,
              sigma=sigma,
              use_sample_covariance=False,
              full=return_ssim_image,
          )
          results[i] = torch.from_numpy(res).type(preds.dtype)
          fullimage = torch.from_numpy(fullimage).type(preds.dtype)
          if len(preds.shape) == 4:
              fullimages[i] = fullimage.permute(2, 0, 1)
          elif len(preds.shape) == 5:
              fullimages[i] = fullimage.permute(3, 0, 1, 2)
      return results, fullimages
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from pytorch_msssim import ssim
  from skimage.metrics import structural_similarity
  from torch import Tensor
  from torchmetrics.functional import structural_similarity_index_measure
  from torchmetrics.image import StructuralSimilarityIndexMeasure
  from unittests import NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 1 for calling a global function with example usage: _skimage_ssim(preds, target, data_range, sigma, kernel_size, return_ssim_image, gaussian_weights, reduction_arg) and returns: results,  fullimages, unknown