I think that I can fix it like this:
class GaussianBlur(nn.Module):
    def __init__(self, input, k_size, sigma):
        super(GaussianBlur, self).__init__()
        
        if input.dim() == 4:
            d_val = 2
            self.groups = input.size(1)
        elif input.dim() == 2:
            d_val = 1
            self.groups = input.size(0)			
            
        k_size, sigma = [k_size] * d_val, [sigma] * d_val
        kernel = 1
        
        meshgrid_tensor = torch.meshgrid([torch.arange(size, dtype=torch.float32, \
        device=input.get_device()) for size in k_size])
        
        for size, std, mgrid in zip(k_size, sigma, meshgrid_tensor):
            kernel *= 1 / (std * math.sqrt(2 * math.pi)) * \
            torch.exp(-((mgrid - ((size - 1) / 2)) / std) ** 2 / 2)

        kernel = (kernel / torch.sum(kernel)).view(1, 1, * kernel.size())
        kernel = kernel.repeat(self.groups, * [1] * (kernel.dim() - 1))
        self.register_buffer('weight', kernel)
        
        if d_val == 2:
            self.conv = torch.nn.functional.conv2d
        elif d_val == 1:
            self.conv = torch.nn.functional.conv1d

    def forward(self, input, pad_mode='reflect'):
        d_val = input.dim()
        if input.dim() > 2:
            input = torch.nn.functional.pad(input, (2, 2, 2, 2), mode=pad_mode)
        else:
            input = input.view(1,1,1000)
        input = self.conv(input, weight=self.weight, groups=self.groups)
        if d_val == 2:
            p1d = nn.ConstantPad1d(2, 0)
            input = p1d(input).view(1,1000)
        return input

Though, I’m not sure if there’s anything wrong with using input.view(1,1,1000) to make a 2 dimension input (size: 1,1000) compatible? It looks like it works in my Laplacian pyramid, but I’m not 100% sure.