class_docstr: Implements "Batch Active learning by Diverse Gradient Embedding" (BADGE) [AZK+20]_.
      
class_docstr_tok: ["Implements","``","Batch","Active","learning","by","Diverse","Gradient","Embedding","''","(","BADGE",")","[","AZK+20","]","_","."]
code: def sample(
      self,
      clf,
      dataset,
      indices_unlabeled,
      indices_labeled,
      y,
      n,
      embeddings,
      embeddings_proba=None,
  ):
      if embeddings_proba is None:
          proba = clf.predict_proba(dataset[indices_unlabeled])
          embeddings = self.get_badge_embeddings(
              embeddings[indices_unlabeled], proba
          )
      else:
          embeddings = self.get_badge_embeddings(
              embeddings[indices_unlabeled],
              embeddings_proba[indices_unlabeled],
          )
  
      _, indices = init_kmeans_plusplus_safe(
          embeddings,
          n,
          x_squared_norms=np.linalg.norm(embeddings, axis=1),
          random_state=np.random.RandomState(),
      )
      return indices
  
imports: import numpy
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.query_strategies import constraints, QueryStrategy, EmbeddingBasedQueryStrategy
  from small_text.utils.clustering import init_kmeans_plusplus_safe
  from small_text.utils.context import build_pbar_context
  from small_text.utils.data import list_length
label_desc: Use image node_id 2 for calling the BADGE obj's underlying member method code with example usage: obj.sample(clf, dataset, indices_unlabeled, indices_labeled, y, n, embeddings, embeddings_proba) and returns: indices