class_docstr: A random shuffling buffer implementation. Items can be added to the buffer and retrieved in a random order.
docstr: Initializes a new ShufflingBuffer instance.
  
  Items may be retrieved from the buffer once ``min_after_retrieve`` items were added to the queue
  (indicated by ``can_retrieve``).
  
  Items may be added to the buffer as long as the number of items in the buffer (not including the items
  passed to :func:`add_many`) does not exceed ``shuffling_queue_capacity``.
  
  The amount of items in the buffer may actually become more than ``shuffling_buffer_capacity`` since
  :func:`add_many` is passed a list of items. The *hard limit* on the number of items in the buffer is
  ``shuffling_buffer_capacity + extra_capacity``.
  
  :param shuffling_buffer_capacity: Items may be added to the buffer as long as the amount of items in the
    buffer does not exceed the value of ``shuffling_queue_capacity`` (not including the items
    passed to :func:`add_many`).
  :param min_after_retrieve: Minimal amount of items in the buffer that allows retrieval. This is needed to
    guarantee good random shuffling of elements. Once :func:`finish` is called, items can be retrieved even if
    the condition does not hold.
  :param extra_capacity: The amount of items in the buffer may grow above ``shuffling_buffer_capacity``
    (due to a call to :func:`add_many` with a list of items), but must remain under ``extra_capacity``. Should be
    set to the upper bound of the number of items that can be added in a single call to :func:`add_many` (can be a
    loose bound).
docstr_tok: ["Initializes","a","new","ShufflingBuffer","instance",".","Items","may","be","retrieved","from","the","buffer","once","``","min_after_retrieve","``","items","were","added","to","the","queue","(","indicated","by","``","can_retrieve","``",")",".","Items","may","be","added","to","the","buffer","as","long","as","the","number","of","items","in","the","buffer","(","not","including","the","items","passed","to",":","func",":","`","add_many","`",")","does","not","exceed","``","shuffling_queue_capacity","``",".","The","amount","of","items","in","the","buffer","may","actually","become","more","than","``","shuffling_buffer_capacity","``","since",":","func",":","`","add_many","`","is","passed","a","list","of","items",".","The","*","hard","limit","*","on","the","number","of","items","in","the","buffer","is","``","shuffling_buffer_capacity","+","extra_capacity","``",".",":","param","shuffling_buffer_capacity",":","Items","may","be","added","to","the","buffer","as","long","as","the","amount","of","items","in","the","buffer","does","not","exceed","the","value","of","``","shuffling_queue_capacity","``","(","not","including","the","items","passed","to",":","func",":","`","add_many","`",")",".",":","param","min_after_retrieve",":","Minimal","amount","of","items","in","the","buffer","that","allows","retrieval",".","This","is","needed","to","guarantee","good","random","shuffling","of","elements",".","Once",":","func",":","`","finish","`","is","called",",","items","can","be","retrieved","even","if","the","condition","does","not","hold",".",":","param","extra_capacity",":","The","amount","of","items","in","the","buffer","may","grow","above","``","shuffling_buffer_capacity","``","(","due","to","a","call","to",":","func",":","`","add_many","`","with","a","list","of","items",")",",","but","must","remain","under","``","extra_capacity","``",".","Should","be","set","to","the","upper","bound","of","the","number","of","items","that","can","be","added","in","a","single","call","to",":","func",":","`","add_many","`","(","can","be","a","loose","bound",")","."]
code: def __init__(
      self,
      shuffling_buffer_capacity,
      min_after_retrieve,
      extra_capacity=1000,
  ):
      """Initializes a new ShufflingBuffer instance.
  
      Items may be retrieved from the buffer once ``min_after_retrieve`` items were added to the queue
      (indicated by ``can_retrieve``).
  
      Items may be added to the buffer as long as the number of items in the buffer (not including the items
      passed to :func:`add_many`) does not exceed ``shuffling_queue_capacity``.
  
      The amount of items in the buffer may actually become more than ``shuffling_buffer_capacity`` since
      :func:`add_many` is passed a list of items. The *hard limit* on the number of items in the buffer is
      ``shuffling_buffer_capacity + extra_capacity``.
  
      :param shuffling_buffer_capacity: Items may be added to the buffer as long as the amount of items in the
        buffer does not exceed the value of ``shuffling_queue_capacity`` (not including the items
        passed to :func:`add_many`).
      :param min_after_retrieve: Minimal amount of items in the buffer that allows retrieval. This is needed to
        guarantee good random shuffling of elements. Once :func:`finish` is called, items can be retrieved even if
        the condition does not hold.
      :param extra_capacity: The amount of items in the buffer may grow above ``shuffling_buffer_capacity``
        (due to a call to :func:`add_many` with a list of items), but must remain under ``extra_capacity``. Should be
        set to the upper bound of the number of items that can be added in a single call to :func:`add_many` (can be a
        loose bound).
      """
      self._extra_capacity = extra_capacity
      # Preallocate the shuffling buffer.
      self._items = [None] * (
          shuffling_buffer_capacity + self._extra_capacity
      )
      self._shuffling_queue_capacity = shuffling_buffer_capacity
      self._min_after_dequeue = min_after_retrieve
      self._size = 0
      self._done_adding = False
  
imports: import abc
  from collections import deque
  import numpy
  import six
label_desc: Use image node_id 1 to create a new RandomShufflingBuffer object from inherited base classes: ShufflingBufferBase with example: obj = RandomShufflingBuffer(shuffling_buffer_capacity, min_after_retrieve, extra_capacity)