class_docstr: Performs bucketing of elements in a dataset by length.
docstr: Initializes the BucketGenerator.
  
  Args:
      element_length_function: Element_length_function: function from element in the dataset to int that
      determines the length of the element.
      batch_size: The size of the batches to bucket the sequences into
          buffer_size_batches: buffer_size_batches: number of batches to keep in internal memory.
      batches_to_bucket: Number of batches in buffer to use for bucketing.
          If set to buffer_size_batches, the resulting batches will be deterministic.
      shuffle: Whether to shuffle elements across batches and the resulting buckets.
      seed: Seed for shuffling.
docstr_tok: ["Initializes","the","BucketGenerator",".","Args",":","element_length_function",":","Element_length_function",":","function","from","element","in","the","dataset","to","int","that","determines","the","length","of","the","element",".","batch_size",":","The","size","of","the","batches","to","bucket","the","sequences","into","buffer_size_batches",":","buffer_size_batches",":","number","of","batches","to","keep","in","internal","memory",".","batches_to_bucket",":","Number","of","batches","in","buffer","to","use","for","bucketing",".","If","set","to","buffer_size_batches",",","the","resulting","batches","will","be","deterministic",".","shuffle",":","Whether","to","shuffle","elements","across","batches","and","the","resulting","buckets",".","seed",":","Seed","for","shuffling","."]
code: def __init__(
      self,
      element_length_function: Callable[..., int],
      batch_size: int,
      buffer_size_batches=1000,
      batches_to_bucket=10,
      shuffle=True,
      seed=None,
  ) -> None:
      """
      Initializes the BucketGenerator.
  
      Args:
          element_length_function: Element_length_function: function from element in the dataset to int that
          determines the length of the element.
          batch_size: The size of the batches to bucket the sequences into
              buffer_size_batches: buffer_size_batches: number of batches to keep in internal memory.
          batches_to_bucket: Number of batches in buffer to use for bucketing.
              If set to buffer_size_batches, the resulting batches will be deterministic.
          shuffle: Whether to shuffle elements across batches and the resulting buckets.
          seed: Seed for shuffling.
      """
  
      self.sequence_length_function = element_length_function
      self.batch_size = batch_size
      self.buffer_size_batches = buffer_size_batches
      self.batches_to_shuffle = batches_to_bucket
      self.shuffle = shuffle
      self.random = Random(seed)
  
file_path: headliner/headliner/preprocessing/bucket_generator.py
imports: from random import Random
  from typing import Iterable, Callable, Iterator, List
label_desc: Use image node_id 1 to create a new BucketGenerator object  with example: obj = BucketGenerator(element_length_function, batch_size, buffer_size_batches, batches_to_bucket, shuffle, seed)