class_docstr: Implements k-center-greedy method.
  
  Args:
      embedding (Tensor): Embedding vector extracted from a CNN
      sampling_ratio (float): Ratio to choose coreset size from the embedding size.
  
  Example:
      >>> embedding.shape
      torch.Size([219520, 1536])
      >>> sampler = KCenterGreedy(embedding=embedding)
      >>> sampled_idxs = sampler.select_coreset_idxs()
      >>> coreset = embedding[sampled_idxs]
      >>> coreset.shape
      torch.Size([219, 1536])
class_docstr_tok: ["Implements","k-center-greedy","method",".","Args",":","embedding","(","Tensor",")",":","Embedding","vector","extracted","from","a","CNN","sampling_ratio","(","float",")",":","Ratio","to","choose","coreset","size","from","the","embedding","size",".","Example",":",">",">",">","embedding.shape","torch.Size","(","[","219520",",","1536","]",")",">",">",">","sampler","=","KCenterGreedy","(","embedding=embedding",")",">",">",">","sampled_idxs","=","sampler.select_coreset_idxs","(",")",">",">",">","coreset","=","embedding","[","sampled_idxs","]",">",">",">","coreset.shape","torch.Size","(","[","219",",","1536","]",")"]
docstr: Select coreset from the embedding.
  
  Args:
      selected_idxs: index of samples already selected. Defaults to an empty set.
  
  Returns:
      Tensor: Output coreset
  
  Example:
      >>> embedding.shape
      torch.Size([219520, 1536])
      >>> sampler = KCenterGreedy(...)
      >>> coreset = sampler.sample_coreset()
      >>> coreset.shape
      torch.Size([219, 1536])
docstr_tok: ["Select","coreset","from","the","embedding",".","Args",":","selected_idxs",":","index","of","samples","already","selected",".","Defaults","to","an","empty","set",".","Returns",":","Tensor",":","Output","coreset","Example",":",">",">",">","embedding.shape","torch.Size","(","[","219520",",","1536","]",")",">",">",">","sampler","=","KCenterGreedy","(","...",")",">",">",">","coreset","=","sampler.sample_coreset","(",")",">",">",">","coreset.shape","torch.Size","(","[","219",",","1536","]",")"]
code: def sample_coreset(
      self, selected_idxs: list[int] | None = None
  ) -> Tensor:
      """Select coreset from the embedding.
  
      Args:
          selected_idxs: index of samples already selected. Defaults to an empty set.
  
      Returns:
          Tensor: Output coreset
  
      Example:
          >>> embedding.shape
          torch.Size([219520, 1536])
          >>> sampler = KCenterGreedy(...)
          >>> coreset = sampler.sample_coreset()
          >>> coreset.shape
          torch.Size([219, 1536])
      """
  
      idxs = self.select_coreset_idxs(selected_idxs)
      coreset = self.embedding[idxs]
  
      return coreset
  
file_path: anomalib/src/anomalib/models/components/sampling/k_center_greedy.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch import Tensor
  from tqdm import tqdm
  from anomalib.models.components.dimensionality_reduction import SparseRandomProjection
label_desc: Use image node_id 6 for calling the KCenterGreedy obj's underlying member method code with example usage: obj.sample_coreset(selected_idxs) and returns: coreset