def compute_kde_scores(self, features: torch.Tensor, as_log_likelihood: bool | None = False) -> torch.Tensor:
        """Compute KDE scores for input features.

        Transforms features via PCA and scaling, then computes KDE scores.

        Args:
            features: Input features of shape (N, D)
            as_log_likelihood: If True, returns log of KDE scores.
                Defaults to False.

        Returns:
            torch.Tensor: KDE scores of shape (N,)
        """
        features = self.pca_model.transform(features)
        features, _ = self.pre_process(features, self.max_length)
        # Scores are always assumed to be passed as a density
        kde_scores = self.kde_model(features)

        # add small constant to avoid zero division in log computation
        kde_scores += 1e-300

        if as_log_likelihood:
            kde_scores = torch.log(kde_scores)

        return kde_scores
Compute KDE scores for input features.

        Transforms features via PCA and scaling, then computes KDE scores.

        Args:
            features: Input features of shape (N, D)
            as_log_likelihood: If True, returns log of KDE scores.
                Defaults to False.

        Returns:
            torch.Tensor: KDE scores of shape (N,)
        
src/anomalib/models/components/classification/kde_classifier.py