class_docstr: Batches are sampled from sorted buckets of data.
  First, partition data in buckets of size `batch_size * mult`.
  Each bucket contains `batch_size * mult` elements. The samples inside each bucket are sorted
  based on sort_key and then batched.
  Parameters
  ----------
  sort_keys : list-like object
      The keys to sort the samples.
  batch_size : int
      Batch size of the sampler.
  mult : int or float, default 100
      The multiplier to determine the bucket size. Each bucket will have size `mult * batch_size`.
  num_parts: int, default 1
    Number of partitions which the data is split into
  part_index: int, default 0
    The index of the part to read from
  shuffle : bool, default False
      Whether to shuffle the data.
  Examples
  --------
  >>> lengths = [np.random.randint(1, 1000) for _ in range(1000)]
  >>> sampler = gluoncv.data.SplitSortedBucketSampler(lengths, 16, 1000)
  >>> # The sequence lengths within the batch will be sorted
  >>> for i, indices in enumerate(sampler):
  ...     if i == 0:
  ...         print([lengths[ele] for ele in indices])
  [-etc-]
class_docstr_tok: ["Batches","are","sampled","from","sorted","buckets","of","data",".","First",",","partition","data","in","buckets","of","size","`","batch_size","*","mult","`",".","Each","bucket","contains","`","batch_size","*","mult","`","elements",".","The","samples","inside","each","bucket","are","sorted","based","on","sort_key","and","then","batched",".","Parameters","--","--","--","--","--","sort_keys",":","list-like","object","The","keys","to","sort","the","samples",".","batch_size",":","int","Batch","size","of","the","sampler",".","mult",":","int","or","float",",","default","100","The","multiplier","to","determine","the","bucket","size",".","Each","bucket","will","have","size","`","mult","*","batch_size","`",".","num_parts",":","int",",","default","1","Number","of","partitions","which","the","data","is","split","into","part_index",":","int",",","default","0","The","index","of","the","part","to","read","from","shuffle",":","bool",",","default","False","Whether","to","shuffle","the","data",".","Examples","--","--","--","--",">",">",">","lengths","=","[","np.random.randint","(","1",",","1000",")","for","_","in","range","(","1000",")","]",">",">",">","sampler","=","gluoncv.data.SplitSortedBucketSampler","(","lengths",",","16",",","1000",")",">",">",">","#","The","sequence","lengths","within","the","batch","will","be","sorted",">",">",">","for","i",",","indices","in","enumerate","(","sampler",")",":","...","if","i","==","0",":","...","print","(","[","lengths","[","ele","]","for","ele","in","indices","]",")","[","-etc-","]"]
code: def __init__(
      self,
      sort_keys,
      batch_size,
      mult=32,
      num_parts=1,
      part_index=0,
      shuffle=False,
      seed=233,
  ):
      assert len(sort_keys) > 0
      assert batch_size > 0
      assert (
          mult >= 1
      ), "Bucket size multiplier must be greater or equal to 1"
      self._sort_keys = sort_keys
      length = len(sort_keys)
      self._batch_size = batch_size
      self._mult = mult
      self._shuffle = shuffle
      # Compute the length of each partition
      part_len = int(np.ceil(float(length) / num_parts))
      # Compute the start index for this partition
      self._start = part_len * part_index
      # Compute the end index for this partition
      self._end = self._start + part_len
      if part_index == num_parts - 1:
          # last part
          self._end = length
          self._start = length - part_len
      self._num_parts = num_parts
      self._seed = seed
      self._shuffled_ids = np.random.RandomState(
          seed=self._seed
      ).permutation(range(length))
  
file_path: gluon-cv/gluoncv/data/sampler.py
imports: import random
  import numpy
  from mxnet import gluon
label_desc: Use image node_id 1 to create a new SplitSortedBucketSampler object from inherited base classes: gluon.data.sampler with example: obj = SplitSortedBucketSampler(sort_keys, batch_size, mult, num_parts, part_index, shuffle, seed)