class_docstr: Local squared zero-normalized cross-correlation.
  The loss is based on a moving kernel/window over the y_true/y_pred,
  within the window the square of zncc is calculated.
  The kernel can be a rectangular / triangular / gaussian window.
  The final loss is the averaged loss over all windows.
  
  Adapted from:
      https://github.com/voxelmorph/voxelmorph/blob/legacy/src/losses.py
      DeepReg (https://github.com/DeepRegNet/DeepReg)
class_docstr_tok: ["Local","squared","zero-normalized","cross-correlation",".","The","loss","is","based","on","a","moving","kernel\/window","over","the","y_true\/y_pred",",","within","the","window","the","square","of","zncc","is","calculated",".","The","kernel","can","be","a","rectangular","\/","triangular","\/","gaussian","window",".","The","final","loss","is","the","averaged","loss","over","all","windows",".","Adapted","from",":","https",":","\/\/github.com\/voxelmorph\/voxelmorph\/blob\/legacy\/src\/losses.py","DeepReg","(","https",":","\/\/github.com\/DeepRegNet\/DeepReg",")"]
docstr: Args:
      spatial_dims: number of spatial dimensions, {``1``, ``2``, ``3``}. Defaults to 3.
      kernel_size: kernel spatial size, must be odd.
      kernel_type: {``"rectangular"``, ``"triangular"``, ``"gaussian"``}. Defaults to ``"rectangular"``.
      reduction: {``"none"``, ``"mean"``, ``"sum"``}
          Specifies the reduction to apply to the output. Defaults to ``"mean"``.
  
          - ``"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.
      smooth_nr: a small constant added to the numerator to avoid nan.
      smooth_dr: a small constant added to the denominator to avoid nan.
docstr_tok: ["Args",":","spatial_dims",":","number","of","spatial","dimensions",",","{","``","1","``",",","``","2","``",",","``","3","``","}",".","Defaults","to","3.","kernel_size",":","kernel","spatial","size",",","must","be","odd",".","kernel_type",":","{","``","``","rectangular","''","``",",","``","``","triangular","''","``",",","``","``","gaussian","''","``","}",".","Defaults","to","``","``","rectangular","''","``",".","reduction",":","{","``","``","none","''","``",",","``","``","mean","''","``",",","``","``","sum","''","``","}","Specifies","the","reduction","to","apply","to","the","output",".","Defaults","to","``","``","mean","''","``",".","-","``","``","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",".","smooth_nr",":","a","small","constant","added","to","the","numerator","to","avoid","nan",".","smooth_dr",":","a","small","constant","added","to","the","denominator","to","avoid","nan","."]
code: def __init__(
      self,
      spatial_dims: int = 3,
      kernel_size: int = 3,
      kernel_type: str = "rectangular",
      reduction: LossReduction | str = LossReduction.MEAN,
      smooth_nr: float = 0.0,
      smooth_dr: float = 1e-5,
  ) -> None:
      """
      Args:
          spatial_dims: number of spatial dimensions, {``1``, ``2``, ``3``}. Defaults to 3.
          kernel_size: kernel spatial size, must be odd.
          kernel_type: {``"rectangular"``, ``"triangular"``, ``"gaussian"``}. Defaults to ``"rectangular"``.
          reduction: {``"none"``, ``"mean"``, ``"sum"``}
              Specifies the reduction to apply to the output. Defaults to ``"mean"``.
  
              - ``"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.
          smooth_nr: a small constant added to the numerator to avoid nan.
          smooth_dr: a small constant added to the denominator to avoid nan.
  
      """
      super().__init__(reduction=LossReduction(reduction).value)
  
      self.ndim = spatial_dims
      if self.ndim not in {1, 2, 3}:
          raise ValueError(
              f"Unsupported ndim: {self.ndim}-d, only 1-d, 2-d, and 3-d inputs are supported"
          )
  
      self.kernel_size = kernel_size
      if self.kernel_size % 2 == 0:
          raise ValueError(
              f"kernel_size must be odd, got {self.kernel_size}"
          )
  
      _kernel = look_up_option(kernel_type, kernel_dict)
      self.kernel = _kernel(self.kernel_size)
      self.kernel.require_grads = False
      self.kernel_vol = self.get_kernel_vol()
  
      self.smooth_nr = float(smooth_nr)
      self.smooth_dr = float(smooth_dr)
  
imports: from __future__ import annotations
  import torch
  from torch.nn import functional
  from torch.nn.modules.loss import _Loss
  from monai.networks.layers import gaussian_1d, separable_filtering
  from monai.utils import LossReduction
  from monai.utils.module import look_up_option
label_desc: Use image node_id 1 to create a new LocalNormalizedCrossCorrelationLoss object from inherited base classes: _Loss with example: obj = LocalNormalizedCrossCorrelationLoss(spatial_dims, kernel_size, kernel_type, reduction, smooth_nr, smooth_dr)