def subsample_embedding(self, embedding: torch.Tensor, sampling_ratio: float) -> None:
        """Subsample embeddings using coreset selection.

        Uses k-center-greedy coreset subsampling to select a representative
        subset of patch embeddings to store in the memory bank.

        Args:
            embedding (torch.Tensor): Embedding tensor to subsample from.
            sampling_ratio (float): Fraction of embeddings to keep, in range (0,1].

        Example:
            >>> embedding = torch.randn(1000, 512)
            >>> model.subsample_embedding(embedding, sampling_ratio=0.1)
            >>> model.memory_bank.shape
            torch.Size([100, 512])
        """
        # Coreset Subsampling
        sampler = KCenterGreedy(embedding=embedding, sampling_ratio=sampling_ratio)
        coreset = sampler.sample_coreset()
        self.memory_bank = coreset
Subsample embeddings using coreset selection.

        Uses k-center-greedy coreset subsampling to select a representative
        subset of patch embeddings to store in the memory bank.

        Args:
            embedding (torch.Tensor): Embedding tensor to subsample from.
            sampling_ratio (float): Fraction of embeddings to keep, in range (0,1].

        Example:
            >>> embedding = torch.randn(1000, 512)
            >>> model.subsample_embedding(embedding, sampling_ratio=0.1)
            >>> model.memory_bank.shape
            torch.Size([100, 512])
        
src/anomalib/models/image/patchcore/torch_model.py