code: def ssim3d_loss(
      img1: Tensor,
      img2: Tensor,
      window_size: int,
      max_val: float = 1.0,
      eps: float = 1e-12,
      reduction: str = "mean",
      padding: str = "same",
  ) -> Tensor:
      r"""Function that computes a loss based on the SSIM measurement.
  
      The loss, or the Structural dissimilarity (DSSIM) is described as:
  
      .. math::
  
        \text{loss}(x, y) = \frac{1 - \text{SSIM}(x, y)}{2}
  
      See :meth:`~kornia.losses.ssim` for details about SSIM.
  
      Args:
          img1: the first input image with shape :math:`(B, C, D, H, W)`.
          img2: the second input image with shape :math:`(B, C, D, H, W)`.
          window_size: the size of the gaussian kernel to smooth the images.
          max_val: the dynamic range of the images.
          eps: Small value for numerically stability when dividing.
          reduction : Specifies the reduction to apply to the
           output: ``'none'`` | ``'mean'`` | ``'sum'``. ``'none'``: no reduction will be applied,
           ``'mean'``: the sum of the output will be divided by the number of elements
           in the output, ``'sum'``: the output will be summed.
          padding: ``'same'`` | ``'valid'``. Whether to only use the "valid" convolution
           area to compute SSIM to match the MATLAB implementation of original SSIM paper.
  
      Returns:
          The loss based on the ssim index.
  
      Examples:
          >>> input1 = torch.rand(1, 4, 5, 5, 5)
          >>> input2 = torch.rand(1, 4, 5, 5, 5)
          >>> loss = ssim3d_loss(input1, input2, 5)
      """
      # compute the ssim map
      ssim_map: Tensor = metrics.ssim3d(
          img1, img2, window_size, max_val, eps, padding
      )
  
      # compute and reduce the loss
      loss = 1.0 - ssim_map
  
      if reduction == "mean":
          loss = loss.mean()
      elif reduction == "sum":
          loss = loss.sum()
      elif reduction == "none":
          pass
      else:
          raise NotImplementedError("Invalid reduction option.")
  
      return loss
  
file_path: kornia/kornia/losses/ssim3d.py
imports: from __future__ import annotations
  from kornia import metrics
  from kornia.core import Module, Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: ssim3d_loss(img1, img2, window_size, max_val, eps, reduction, padding) and returns: loss