def __init__(self, n_neighbors: int) -> None:
        """Initialize the grouped KNN density estimator.

        Args:
            n_neighbors (int): Number of neighbors used in KNN search.
        """
        super().__init__()

        self.n_neighbors = n_neighbors
        self.feature_collection: dict[str, list[torch.Tensor]] = {}
        self.group_index: dict[str, int] = {}

        self.register_buffer("memory_bank", Tensor())
        self.register_buffer("min", torch.tensor(torch.inf))
        self.register_buffer("max", torch.tensor(-torch.inf))

        self.memory_bank: torch.Tensor
        self.min: torch.Tensor
        self.max: torch.Tensor
Initialize the grouped KNN density estimator.

        Args:
            n_neighbors (int): Number of neighbors used in KNN search.
        
src/anomalib/models/video/ai_vad/density.py