import torch


def _fspecial_gauss_1d(size, sigma, device=None, dtype=None):
    """
    Create a 1D gaussian kernel
    Parameters
    ----------
    size : int
        The size of the gaussian kernel
    sigma : float
        The standard deviation of the normal distribution
    Returns
    -------
    torch.Tensor: 1D kernel (1 x 1 x size)
    """
    coords = torch.arange(size, dtype=dtype, device=device).float()
    coords -= size // 2
    g = torch.exp(-(coords**2) / (2 * sigma**2))
    g /= g.sum()
    # Return window as 1x1xsize
    return g.view(1, 1, *g.shape)