code: def _gaussian_kernel(
      spatial_dims: int,
      num_channels: int,
      kernel_size: Sequence[int],
      kernel_sigma: Sequence[float],
  ) -> torch.Tensor:
      """Computes 2D or 3D gaussian kernel.
  
      Args:
          spatial_dims: number of spatial dimensions of the input images.
          num_channels: number of channels in the image
          kernel_size: size of kernel
          kernel_sigma: standard deviation for Gaussian kernel.
      """
  
      def gaussian_1d(kernel_size: int, sigma: float) -> torch.Tensor:
          """Computes 1D gaussian kernel.
  
          Args:
              kernel_size: size of the gaussian kernel
              sigma: Standard deviation of the gaussian kernel
          """
          dist = torch.arange(
              start=(1 - kernel_size) / 2,
              end=(1 + kernel_size) / 2,
              step=1,
          )
          gauss = torch.exp(-torch.pow(dist / sigma, 2) / 2)
          return (gauss / gauss.sum()).unsqueeze(dim=0)
  
      gaussian_kernel_x = gaussian_1d(kernel_size[0], kernel_sigma[0])
      gaussian_kernel_y = gaussian_1d(kernel_size[1], kernel_sigma[1])
      kernel = torch.matmul(
          gaussian_kernel_x.t(), gaussian_kernel_y
      )  # (kernel_size, 1) * (1, kernel_size)
  
      kernel_dimensions: tuple[int, ...] = (
          num_channels,
          1,
          kernel_size[0],
          kernel_size[1],
      )
  
      if spatial_dims == 3:
          gaussian_kernel_z = gaussian_1d(
              kernel_size[2], kernel_sigma[2]
          )[
              None,
          ]
          kernel = torch.mul(
              kernel.unsqueeze(-1).repeat(1, 1, kernel_size[2]),
              gaussian_kernel_z.expand(
                  kernel_size[0], kernel_size[1], kernel_size[2]
              ),
          )
          kernel_dimensions = (
              num_channels,
              1,
              kernel_size[0],
              kernel_size[1],
              kernel_size[2],
          )
  
      return kernel.expand(kernel_dimensions)
  
imports: from __future__ import annotations
  import math
  from abc import abstractmethod
  from collections.abc import Callable, Sequence
  from functools import partial
  from typing import Any
  import torch
  import torch.nn.functional
  from monai.metrics.utils import do_metric_reduction
  from monai.utils import MetricReduction, StrEnum, convert_data_type, ensure_tuple_rep
  from monai.utils.type_conversion import convert_to_dst_type
  from .metric import CumulativeIterationMetric
label_desc: Use image node_id 2 for calling a global function with example usage: _gaussian_kernel(spatial_dims, num_channels, kernel_size, kernel_sigma) and returns: kernel, unknown