def forward(self, input_tensor: torch.Tensor) -> torch.Tensor:
        """Apply Gaussian blur to input tensor.

        Args:
            input_tensor (torch.Tensor): Input tensor of shape
                ``(B, C, H, W)``.

        Returns:
            torch.Tensor: Blurred output tensor. If padding is 'same',
                output shape matches input. If 'valid', output is smaller.

        Example:
            >>> blur = GaussianBlur2d(sigma=1.0, channels=1)
            >>> x = torch.ones(1, 1, 5, 5)
            >>> output = blur(x)
            >>> output.shape
            torch.Size([1, 1, 5, 5])
        """
        batch, channel, height, width = input_tensor.size()

        if self.padding == "same":
            input_tensor = F.pad(input_tensor, self.padding_shape, mode=self.border_type)

        # convolve the tensor with the kernel.
        output = F.conv2d(input_tensor, self.kernel, groups=self.channels, padding=0, stride=1)

        if self.padding == "same":
            out = output.view(batch, channel, height, width)
        else:
            out = output.view(batch, channel, height - self.height + 1, width - self.width + 1)

        return out
Apply Gaussian blur to input tensor.

        Args:
            input_tensor (torch.Tensor): Input tensor of shape
                ``(B, C, H, W)``.

        Returns:
            torch.Tensor: Blurred output tensor. If padding is 'same',
                output shape matches input. If 'valid', output is smaller.

        Example:
            >>> blur = GaussianBlur2d(sigma=1.0, channels=1)
            >>> x = torch.ones(1, 1, 5, 5)
            >>> output = blur(x)
            >>> output.shape
            torch.Size([1, 1, 5, 5])
        
src/anomalib/models/components/filters/blur.py