class_docstr: Differentiable global mutual information loss via Parzen windowing method.
  
  Reference:
      https://dspace.mit.edu/handle/1721.1/123142, Section 3.1, equation 3.1-3.5, Algorithm 1
class_docstr_tok: ["Differentiable","global","mutual","information","loss","via","Parzen","windowing","method",".","Reference",":","https",":","\/\/dspace.mit.edu\/handle\/1721.1\/123142",",","Section","3.1",",","equation","3.1-3.5",",","Algorithm","1"]
docstr: Parzen windowing with gaussian kernel (adapted from DeepReg implementation)
  Note: the input is expected to range between 0 and 1
  Args:
      img: the shape should be B[NDHW].
docstr_tok: ["Parzen","windowing","with","gaussian","kernel","(","adapted","from","DeepReg","implementation",")","Note",":","the","input","is","expected","to","range","between","0","and","1","Args",":","img",":","the","shape","should","be","B","[","NDHW","]","."]
code: def parzen_windowing_gaussian(
      self, img: torch.Tensor
  ) -> tuple[torch.Tensor, torch.Tensor]:
      """
      Parzen windowing with gaussian kernel (adapted from DeepReg implementation)
      Note: the input is expected to range between 0 and 1
      Args:
          img: the shape should be B[NDHW].
      """
      img = torch.clamp(img, 0, 1)
      img = img.reshape(img.shape[0], -1, 1)  # (batch, num_sample, 1)
      weight = torch.exp(
          -self.preterm.to(img) * (img - self.bin_centers.to(img)) ** 2
      )  # (batch, num_sample, num_bin)
      weight = weight / torch.sum(
          weight, dim=-1, keepdim=True
      )  # (batch, num_sample, num_bin)
      probability = torch.mean(
          weight, dim=-2, keepdim=True
      )  # (batch, 1, num_bin)
      return weight, probability
  
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 4 for calling the GlobalMutualInformationLoss obj's underlying member method code with example usage: obj.parzen_windowing_gaussian(img) and returns: weight,  probability