class_docstr: Data manager for sampling data, use reservoir sampling.
      
docstr: Add an item to bucket, replacing an old item with probability.
  
  Use reservoir sampling to add a new item to sampling bucket,
  each item in a steam has same probability stay in the bucket.
  
  Args:
      item: The item to add to reservoir bucket.
docstr_tok: ["Add","an","item","to","bucket",",","replacing","an","old","item","with","probability",".","Use","reservoir","sampling","to","add","a","new","item","to","sampling","bucket",",","each","item","in","a","steam","has","same","probability","stay","in","the","bucket",".","Args",":","item",":","The","item","to","add","to","reservoir","bucket","."]
code: def add_item(self, item):
      """Add an item to bucket, replacing an old item with probability.
  
      Use reservoir sampling to add a new item to sampling bucket,
      each item in a steam has same probability stay in the bucket.
  
      Args:
          item: The item to add to reservoir bucket.
      """
      with self._mutex:
          if len(self._items) < self._max_size or self._max_size == 0:
              self._items.append(item)
          else:
              r = self._random.randint(1, self._num_items_index)
              if r < self._max_size:
                  self._items.pop(r)
                  self._items.append(item)
              else:
                  self._items[-1] = item
          self._num_items_index += 1
  
imports: import collections
  import random
  import threading
label_desc: Use image node_id 2 for calling the _ReservoirBucket obj's underlying member method code with example usage: obj.add_item(item) without return types