class_docstr: Compute the loss function based on the Structural Similarity Index Measure (SSIM) Metric.
  
  For more info, visit
      https://vicuesoft.com/glossary/term/ssim-ms-ssim/
  
  SSIM reference paper:
      Wang, Zhou, et al. "Image quality assessment: from error visibility to structural
      similarity." IEEE transactions on image processing 13.4 (2004): 600-612.
docstr: Args:
      input: batch of predicted images with shape (batch_size, channels, spatial_dim1, spatial_dim2[, spatial_dim3])
      target: batch of target images with shape (batch_size, channels, spatial_dim1, spatial_dim2[, spatial_dim3])
  
  Returns:
      1 minus the ssim index (recall this is meant to be a loss function)
  
  Example:
      .. code-block:: python
  
          import torch
  
          # 2D data
          x = torch.ones([1,1,10,10])/2
          y = torch.ones([1,1,10,10])/2
          print(1-SSIMLoss(spatial_dims=2)(x,y))
  
          # pseudo-3D data
          x = torch.ones([1,5,10,10])/2  # 5 could represent number of slices
          y = torch.ones([1,5,10,10])/2
          print(1-SSIMLoss(spatial_dims=2)(x,y))
  
          # 3D data
          x = torch.ones([1,1,10,10,10])/2
          y = torch.ones([1,1,10,10,10])/2
          print(1-SSIMLoss(spatial_dims=3)(x,y))
code: def forward(
      self, input: torch.Tensor, target: torch.Tensor
  ) -> torch.Tensor:
      """
      Args:
          input: batch of predicted images with shape (batch_size, channels, spatial_dim1, spatial_dim2[, spatial_dim3])
          target: batch of target images with shape (batch_size, channels, spatial_dim1, spatial_dim2[, spatial_dim3])
  
      Returns:
          1 minus the ssim index (recall this is meant to be a loss function)
  
      Example:
          .. code-block:: python
  
              import torch
  
              # 2D data
              x = torch.ones([1,1,10,10])/2
              y = torch.ones([1,1,10,10])/2
              print(1-SSIMLoss(spatial_dims=2)(x,y))
  
              # pseudo-3D data
              x = torch.ones([1,5,10,10])/2  # 5 could represent number of slices
              y = torch.ones([1,5,10,10])/2
              print(1-SSIMLoss(spatial_dims=2)(x,y))
  
              # 3D data
              x = torch.ones([1,1,10,10,10])/2
              y = torch.ones([1,1,10,10,10])/2
              print(1-SSIMLoss(spatial_dims=3)(x,y))
      """
      ssim_value = self.ssim_metric._compute_tensor(input, target).view(
          -1, 1
      )
      loss: torch.Tensor = 1 - ssim_value
  
      if self.reduction == LossReduction.MEAN.value:
          loss = torch.mean(loss)  # the batch average
      elif self.reduction == LossReduction.SUM.value:
          loss = torch.sum(loss)  # sum over the batch
  
      return loss
  
file_path: MONAI/monai/losses/ssim_loss.py
imports: from __future__ import annotations
  from collections.abc import Sequence
  import torch
  from torch.nn.modules.loss import _Loss
  from monai.metrics.regression import KernelType, SSIMMetric
  from monai.utils import LossReduction, ensure_tuple_rep
label_desc: Use image node_id 4 for calling the SSIMLoss obj's underlying member method code with example usage: obj.forward(input, target) and returns: loss