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
      paddle.Size([219520, 1536])
      >>> sampler = KCenterGreedy(embedding=embedding)
      >>> sampled_idxs = sampler.select_coreset_idxs()
      >>> coreset = embedding[sampled_idxs]
      >>> coreset.shape
      paddle.Size([219, 1536])
docstr: Greedily form a coreset to minimize the maximum distance of a cluster.
  
  Args:
      selected_idxs: index of samples already selected. Defaults to an empty set.
  
  Returns:
    indices of samples selected to minimize distance to cluster centers
docstr_tok: ["Greedily","form","a","coreset","to","minimize","the","maximum","distance","of","a","cluster",".","Args",":","selected_idxs",":","index","of","samples","already","selected",".","Defaults","to","an","empty","set",".","Returns",":","indices","of","samples","selected","to","minimize","distance","to","cluster","centers"]
code: def select_coreset_idxs(
      self, selected_idxs: Optional[List[int]] = None
  ) -> List[int]:
      """Greedily form a coreset to minimize the maximum distance of a cluster.
  
      Args:
          selected_idxs: index of samples already selected. Defaults to an empty set.
  
      Returns:
        indices of samples selected to minimize distance to cluster centers
      """
  
      if selected_idxs is None:
          selected_idxs = []
      # w = torch.load('../anomalib/random_matrix.pth',map_location=torch.device('cpu')).numpy()
      if self.embedding.ndim == 2:
          self.model.fit(self.embedding)
          self.features = self.model.transform(self.embedding)
          self.reset_distances()
      else:
          self.features = self.embedding.reshape(
              (self.embedding.shape[0], -1)
          )
          self.update_distances(cluster_centers=selected_idxs)
  
      selected_coreset_idxs = []
      idx = paddle.randint(
          high=self.n_observations, shape=(1,)
      )  # .item()
      for _ in range(self.coreset_size):
          self.update_distances(cluster_centers=[idx])
          idx = paddle.argmax(self.min_distances)
          # if idx in selected_idxs:
          #    raise ValueError("New indices should not be in selected indices.")
          self.min_distances[idx] = 0
          selected_coreset_idxs.append(idx)
  
      return paddle.concat(selected_coreset_idxs)
  
file_path: PaddleSeg/contrib/QualityInspector/qinspector/uad/utils/k_center_greedy.py
imports: from typing import List, Optional
  import paddle
  from paddle import Tensor
  from .random_projection import SparseRandomProjection
label_desc: Use image node_id 4 for calling the KCenterGreedy obj's underlying member method code with example usage: obj.select_coreset_idxs(selected_idxs) and returns: paddle