def compute_scores(
        self,
        features: torch.Tensor,
        feature_shapes: tuple,
    ) -> tuple[torch.Tensor, torch.Tensor]:
        """Compute anomaly scores.

        Scores are PCA-based feature reconstruction error (FRE) scores.

        Args:
            features (torch.Tensor): Features for scoring with shape
                ``(n_samples, n_features)``.
            feature_shapes (tuple): Shape of features tensor for anomaly map.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: Tuple containing
                (scores, anomaly_maps).
        """
        feats_projected = self.pca_model.transform(features)
        feats_reconstructed = self.pca_model.inverse_transform(feats_projected)
        fre_prereshape = torch.square(features - feats_reconstructed)
        fre = fre_prereshape.reshape(feature_shapes)
        score_map = torch.sum(fre, dim=(1, 2))  # NxTxCxHxW->NxHxW
        score = torch.sum(score_map, axis=(1, 2))  # NxHxW->N
        return score, score_map
Compute anomaly scores.

        Scores are PCA-based feature reconstruction error (FRE) scores.

        Args:
            features (torch.Tensor): Features for scoring with shape
                ``(n_samples, n_features)``.
            feature_shapes (tuple): Shape of features tensor for anomaly map.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: Tuple containing
                (scores, anomaly_maps).
        
src/anomalib/models/video/fuvas/torch_model.py