class_docstr: Buketized BatchSampler for sequential data with different lengths to reduce number of paddings.
  
  Args:
      lengths (List[int]): The lengths of the samples in the dataset.
      num_buckets (int): The number of buckets to split the data samples.
      min_len (int, optional): The minimum sample lengths to keep.
          (Default: 0)
      max_len (int or None, optional): The maximum sample lengths to keep. Inferred if not provided.
          (Default ``None``)
      max_token_count (int or None, optional): The max number of tokens in one mini-batch.
          (Default: ``None``)
      batch_size (int or None, optional): The number of samples in one mini-batch.
          (Default: ``None``)
      shuffle (bool, optional): Whether to shuffle buckets for non-monotonic length sampling.
          (Default: True)
      seed (int, optional): The seed for initialzing RNG. Only used when `shuffle` is True. (Default: 0)
      drop_last (bool, optional): If ``True``, the sampler will drop the last batch if
          its size would be less than ``batch_size``
          (Default: False)
  
  Note:
      ``max_token_count`` and ``batch_size`` are mutually exclusive. Only one argument of the two
      should have value.
  
  Note:
      ``drop_last`` is only valid when ``batch_size`` argument is given.
  
  Note:
      if ``shuffle`` is True, it will only shuffle the data once. Please set ``reload_dataloaders_every_n_epochs=1``
      in pytorch_lightning Trainer and set ``seed`` to ``self.trainer.current_epoch`` to enable shuffling every epoch.
docstr: Generate buckets based on the dataset.
  Args:
      lengths (List[int]): The lengths of the samples in the dataset.
      num_buckets (int): The number of buckets.
      min_len (int): The lower bound of the evenly spaced length intervals to determine bucket width.
      max_len (int): The upper bound of the evenly spaced length intervals to determine bucket width.
  
  Returns:
      (dict[int, Tensor]): A dictionary in which the key is the bucket index, the value is
          the Tensor of corresponding sample indices.
docstr_tok: ["Generate","buckets","based","on","the","dataset",".","Args",":","lengths","(","List","[","int","]",")",":","The","lengths","of","the","samples","in","the","dataset",".","num_buckets","(","int",")",":","The","number","of","buckets",".","min_len","(","int",")",":","The","lower","bound","of","the","evenly","spaced","length","intervals","to","determine","bucket","width",".","max_len","(","int",")",":","The","upper","bound","of","the","evenly","spaced","length","intervals","to","determine","bucket","width",".","Returns",":","(","dict","[","int",",","Tensor","]",")",":","A","dictionary","in","which","the","key","is","the","bucket","index",",","the","value","is","the","Tensor","of","corresponding","sample","indices","."]
code: def _get_buckets(
      self,
      lengths: List[int],
      num_buckets: int,
      min_len: int,
      max_len: int,
  ) -> Dict[int, Tensor]:
      """Generate buckets based on the dataset.
      Args:
          lengths (List[int]): The lengths of the samples in the dataset.
          num_buckets (int): The number of buckets.
          min_len (int): The lower bound of the evenly spaced length intervals to determine bucket width.
          max_len (int): The upper bound of the evenly spaced length intervals to determine bucket width.
  
      Returns:
          (dict[int, Tensor]): A dictionary in which the key is the bucket index, the value is
              the Tensor of corresponding sample indices.
      """
      buckets = {}
      boundaries = torch.linspace(
          min_len - 1, max_len + 1, num_buckets + 1
      )
      bucket_ids = torch.bucketize(torch.tensor(lengths), boundaries)
      for i in range(bucket_ids.size(0)):
          bucket_id = int(bucket_ids[i])
          if bucket_id in buckets:
              buckets[bucket_id].append(i)
          else:
              buckets[bucket_id] = [i]
      for k in buckets:
          buckets[k] = torch.as_tensor(buckets[k], dtype=torch.int)
      buckets = {k: v for k, v in sorted(buckets.items())}
      return buckets
  
imports: import math
  from pathlib import Path
  from typing import Dict, Iterator, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.distributed
  import torchaudio
  from torch import Tensor
  from torch.utils.data import BatchSampler, Dataset, DistributedSampler
  from ..lightning_modules import Batch
label_desc: Use image node_id 2 for calling the BucketizeBatchSampler obj's underlying member method code with example usage: obj._get_buckets(lengths, num_buckets, min_len, max_len) and returns: buckets