class_docstr: Chunks blocks into shuffled batches, using a local in-memory shuffle buffer.
docstr: Constructs a random-shuffling block batcher.
  
  Args:
      batch_size: Record batch size.
      shuffle_buffer_min_size: Minimum number of rows that must be in the local
          in-memory shuffle buffer in order to yield a batch. When there are no
          more rows to be added to the buffer, the number of rows in the buffer
          *will* decrease below this value while yielding the remaining batches,
          and the final batch may have less than ``batch_size`` rows. Increasing
          this will improve the randomness of the shuffle but may increase the
          latency to the first batch.
      shuffle_seed: The seed to use for the local random shuffle.
docstr_tok: ["Constructs","a","random-shuffling","block","batcher",".","Args",":","batch_size",":","Record","batch","size",".","shuffle_buffer_min_size",":","Minimum","number","of","rows","that","must","be","in","the","local","in-memory","shuffle","buffer","in","order","to","yield","a","batch",".","When","there","are","no","more","rows","to","be","added","to","the","buffer",",","the","number","of","rows","in","the","buffer","*","will","*","decrease","below","this","value","while","yielding","the","remaining","batches",",","and","the","final","batch","may","have","less","than","``","batch_size","``","rows",".","Increasing","this","will","improve","the","randomness","of","the","shuffle","but","may","increase","the","latency","to","the","first","batch",".","shuffle_seed",":","The","seed","to","use","for","the","local","random","shuffle","."]
code: def __init__(
      self,
      batch_size: Optional[int],
      shuffle_buffer_min_size: int,
      shuffle_seed: Optional[int] = None,
  ):
      """Constructs a random-shuffling block batcher.
  
      Args:
          batch_size: Record batch size.
          shuffle_buffer_min_size: Minimum number of rows that must be in the local
              in-memory shuffle buffer in order to yield a batch. When there are no
              more rows to be added to the buffer, the number of rows in the buffer
              *will* decrease below this value while yielding the remaining batches,
              and the final batch may have less than ``batch_size`` rows. Increasing
              this will improve the randomness of the shuffle but may increase the
              latency to the first batch.
          shuffle_seed: The seed to use for the local random shuffle.
      """
      if batch_size is None:
          raise ValueError(
              "Must specify a batch_size if using a local shuffle."
          )
      self._batch_size = batch_size
      self._shuffle_seed = shuffle_seed
      if shuffle_buffer_min_size < batch_size:
          # Round it up internally to `batch_size` since our algorithm requires it.
          # This is harmless since it only offers extra randomization.
          shuffle_buffer_min_size = batch_size
      self._buffer_capacity = max(
          2 * shuffle_buffer_min_size,
          shuffle_buffer_min_size + batch_size,
      )
      self._buffer_min_size = shuffle_buffer_min_size
      self._builder = DelegatingBlockBuilder()
      self._shuffle_buffer: Block = None
      self._batch_head = 0
      self._done_adding = False
  
imports: from typing import Optional
  from ray.data._internal.arrow_block import ArrowBlockAccessor
  from ray.data._internal.arrow_ops import transform_pyarrow
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
  from ray.data.block import Block, BlockAccessor
label_desc: Use image node_id 1 to create a new ShufflingBatcher object from inherited base classes: BatcherInterface with example: obj = ShufflingBatcher(batch_size, shuffle_buffer_min_size, shuffle_seed)