docstr: Heuristic that is stochastic to improve diversity.
  
  Common acquisition functions are heavily impacted by duplicates.
  When using a `top-k` approache where the most
  uncertain examples are selected, the acquisition function can select many duplicates.
  Techniques such as BADGE (Ash et al, 2019) or BatchBALD (Kirsh et al. 2019)
  are common solutions to this problem, but they are quite expensive.
  
  Stochastic acquisitions are cheap to compute and get similar performances.
  
  References:
      Stochastic Batch Acquisition for Deep Active Learning, Kirsch et al. (2022)
      https://arxiv.org/abs/2106.12059
  
  Args:
      base_heuristic: Heuristic to get uncertainty from before sampling.
      query_size: These heuristics will return `query_size` items.
docstr_tok: ["Heuristic","that","is","stochastic","to","improve","diversity",".","Common","acquisition","functions","are","heavily","impacted","by","duplicates",".","When","using","a","`","top-k","`","approache","where","the","most","uncertain","examples","are","selected",",","the","acquisition","function","can","select","many","duplicates",".","Techniques","such","as","BADGE","(","Ash","et","al",",","2019",")","or","BatchBALD","(","Kirsh","et","al",".","2019",")","are","common","solutions","to","this","problem",",","but","they","are","quite","expensive",".","Stochastic","acquisitions","are","cheap","to","compute","and","get","similar","performances",".","References",":","Stochastic","Batch","Acquisition","for","Deep","Active","Learning",",","Kirsch","et","al",".","(","2022",")","https",":","\/\/arxiv.org\/abs\/2106.12059","Args",":","base_heuristic",":","Heuristic","to","get","uncertainty","from","before","sampling",".","query_size",":","These","heuristics","will","return","`","query_size","`","items","."]
code: def __init__(self, base_heuristic: AbstractHeuristic, query_size):
      """Heuristic that is stochastic to improve diversity.
  
      Common acquisition functions are heavily impacted by duplicates.
      When using a `top-k` approache where the most
      uncertain examples are selected, the acquisition function can select many duplicates.
      Techniques such as BADGE (Ash et al, 2019) or BatchBALD (Kirsh et al. 2019)
      are common solutions to this problem, but they are quite expensive.
  
      Stochastic acquisitions are cheap to compute and get similar performances.
  
      References:
          Stochastic Batch Acquisition for Deep Active Learning, Kirsch et al. (2022)
          https://arxiv.org/abs/2106.12059
  
      Args:
          base_heuristic: Heuristic to get uncertainty from before sampling.
          query_size: These heuristics will return `query_size` items.
      """
      # TODO handle reverse
      super().__init__(reverse=False)
      self._bh = base_heuristic
      self.query_size = query_size
  
imports: import types
  import numpy
  import structlog
  from scipy.special import softmax
  from scipy.stats import rankdata
  from baal.active.heuristics import AbstractHeuristic, Sequence
label_desc: Use image node_id 1 to create a new StochasticHeuristic object from inherited base classes: AbstractHeuristic with example: obj = StochasticHeuristic(base_heuristic, query_size)