def _compute_few_shot_scores(
        self,
        patch_embeddings: torch.Tensor,
        window_embeddings: list[torch.Tensor],
    ) -> torch.Tensor:
        """Compute multi-scale anomaly score maps using reference embeddings.

        Visual association scores are computed between extracted embeddings and
        reference embeddings at each scale. Window scores are aggregated into score
        maps per scale using harmonic averaging. Final maps obtained by averaging
        across scales.

        Args:
            patch_embeddings (torch.Tensor): Full-scale patch embeddings of shape
                ``(batch_size, n_patches, n_features)``.
            window_embeddings (list[torch.Tensor]): Window embeddings list, each of
                shape ``(batch_size, n_windows, n_features)``.

        Returns:
            torch.Tensor: Few-shot scores of shape ``(batch_size, H, W)``.
        """
        multi_scale_scores = [
            visual_association_score(patch_embeddings, self.patch_embeddings).reshape((-1, *self.grid_size)),
        ]
        for window_embedding, reference_embedding, mask in zip(
            window_embeddings,
            self.visual_embeddings,
            self.masks,
            strict=True,
        ):
            scores = visual_association_score(window_embedding, reference_embedding)
            multi_scale_scores.append(harmonic_aggregation(scores, self.grid_size, mask))

        return torch.stack(multi_scale_scores).mean(dim=0)
Compute multi-scale anomaly score maps using reference embeddings.

        Visual association scores are computed between extracted embeddings and
        reference embeddings at each scale. Window scores are aggregated into score
        maps per scale using harmonic averaging. Final maps obtained by averaging
        across scales.

        Args:
            patch_embeddings (torch.Tensor): Full-scale patch embeddings of shape
                ``(batch_size, n_patches, n_features)``.
            window_embeddings (list[torch.Tensor]): Window embeddings list, each of
                shape ``(batch_size, n_windows, n_features)``.

        Returns:
            torch.Tensor: Few-shot scores of shape ``(batch_size, H, W)``.
        
src/anomalib/models/image/winclip/torch_model.py