code: def _gaussian_window(
      window_size: int,
      std: float,
      device: Optional[torch.device] = None,
      dtype: Optional[torch.dtype] = None,
  ) -> Tensor:
      """Constructs a 2D Gaussian window, as used in the MS-SSIM paper."""
  
      if window_size <= 0 or window_size % 2 == 0:
          raise ValueError(
              f"Window size must be positive odd number, not {window_size}"
          )
  
      indices = torch.arange(
          -(window_size // 2),
          window_size // 2 + 1,
          device=device,
          dtype=dtype,
      )
  
      # Ignoring the constant factor in the Gaussian formula, since
      # the probabilities are immediately normalized below.
      gaussian_probabilities = torch.exp(-0.5 * (indices / std).pow(2))
  
      normalized = gaussian_probabilities / gaussian_probabilities.sum()
      window = normalized[:, None] * normalized[None, :]
      return window.view(1, 1, window_size, window_size)
  
file_path: NeuralCompression/neuralcompression/functional/_multiscale_structural_similarity.py
imports: from typing import Callable, Optional, Sequence
  import torch
  from torch import Tensor
  from torch.nn import functional
label_desc: Use image node_id 1 for calling a global function with example usage: _gaussian_window(window_size, std, device, dtype) and returns: window