class_docstr: Performs bucketing of elements in a dataset by length.
code: def _to_buckets(self, buffered_data: List) -> List[List]:
      self._shuffle_if_required(buffered_data)
      buffered_data = self._sort_blocks(buffered_data)
      buckets = []
      for i in range(0, len(buffered_data), self.batch_size):
          bucket = buffered_data[i : i + self.batch_size]
          if len(bucket) == self.batch_size:
              buckets.append(bucket)
      self._shuffle_if_required(buckets)
      return buckets
  
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 4 for calling the BucketGenerator obj's underlying member method code with example usage: obj._to_buckets(buffered_data) and returns: buckets