code: def gaussian_1d(
      sigma: torch.Tensor,
      truncated: float = 4.0,
      approx: str = "erf",
      normalize: bool = False,
  ) -> torch.Tensor:
      """
      one dimensional Gaussian kernel.
  
      Args:
          sigma: std of the kernel
          truncated: tail length
          approx: discrete Gaussian kernel type, available options are "erf", "sampled", and "scalespace".
  
              - ``erf`` approximation interpolates the error function;
              - ``sampled`` uses a sampled Gaussian kernel;
              - ``scalespace`` corresponds to
                https://en.wikipedia.org/wiki/Scale_space_implementation#The_discrete_Gaussian_kernel
                based on the modified Bessel functions.
  
          normalize: whether to normalize the kernel with `kernel.sum()`.
  
      Raises:
          ValueError: When ``truncated`` is non-positive.
  
      Returns:
          1D torch tensor
  
      """
      sigma = torch.as_tensor(
          sigma,
          dtype=torch.float,
          device=sigma.device
          if isinstance(sigma, torch.Tensor)
          else None,
      )
      device = sigma.device
      if truncated <= 0.0:
          raise ValueError(
              f"truncated must be positive, got {truncated}."
          )
      tail = int(max(float(sigma) * truncated, 0.5) + 0.5)
      if approx.lower() == "erf":
          x = torch.arange(
              -tail, tail + 1, dtype=torch.float, device=device
          )
          t = 0.70710678 / torch.abs(sigma)
          out = 0.5 * ((t * (x + 0.5)).erf() - (t * (x - 0.5)).erf())
          out = out.clamp(min=0)
      elif approx.lower() == "sampled":
          x = torch.arange(
              -tail, tail + 1, dtype=torch.float, device=sigma.device
          )
          out = torch.exp(-0.5 / (sigma * sigma) * x**2)
          if not normalize:  # compute the normalizer
              out = out / (2.5066282 * sigma)
      elif approx.lower() == "scalespace":
          sigma2 = sigma * sigma
          out_pos: list[torch.Tensor | None] = [None] * (tail + 1)
          out_pos[0] = _modified_bessel_0(sigma2)
          out_pos[1] = _modified_bessel_1(sigma2)
          for k in range(2, len(out_pos)):
              out_pos[k] = _modified_bessel_i(k, sigma2)
          out = out_pos[:0:-1]
          out.extend(out_pos)
          out = torch.stack(out) * torch.exp(-sigma2)
      else:
          raise NotImplementedError(
              f"Unsupported option: approx='{approx}'."
          )
      return out / out.sum() if normalize else out
  
file_path: MONAI/monai/networks/layers/convutils.py
imports: from __future__ import annotations
  from collections.abc import Sequence
  import numpy
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: gaussian_1d(sigma, truncated, approx, normalize) and returns: unknown