class_docstr: Assign each data sample to bounded budget batches.
  We will ensure that within the batch,
  the total number of tokens is smaller than the provided max_num_tokens,
  and the total number of sentences is smaller than the provided max_num_sentences.
  
  Samples will be sorted by length before batchify
  See Also https://github.com/pytorch/fairseq/blob/master/fairseq/data/data_utils_fast.pyx
  
  Parameters
  ----------
  lengths
      The length of the sequences in the input data sample.
      For example, can be [500, 100, 200], or [[100, 102], [200, 100], [500, 12]]
  max_num_tokens
      Max number of tokens of each batch
  max_num_sentences
      Max number of sentences of each batch
  required_batch_size_multiple
      Require batch size to be a multiple of N (default: 1).
      This will generally have better throughput in GPU.
  sort_type
      The way we sort the sample.
      - sequential:
          We sort the indices based on the individual lengths.
          For example, each sample has (src_length, tgt_length).
          We will sort them as
          indices = indices[argsort(lengths[:, 1])]
          indices = indices[argsort(lengths[:, 0])]
      - max:
          Take the max of the lengths and sort by the max value.
          indices = indices[argsort(lengths.max(axis=-1)]
      - first:
          Just sort with the first length
          indices = indices[argsort(lengths[:, 0]]
  shuffle
      Whether to shuffle the batches.
  seed
      The seed of the sampler
class_docstr_tok: ["Assign","each","data","sample","to","bounded","budget","batches",".","We","will","ensure","that","within","the","batch",",","the","total","number","of","tokens","is","smaller","than","the","provided","max_num_tokens",",","and","the","total","number","of","sentences","is","smaller","than","the","provided","max_num_sentences",".","Samples","will","be","sorted","by","length","before","batchify","See","Also","https",":","\/\/github.com\/pytorch\/fairseq\/blob\/master\/fairseq\/data\/data_utils_fast.pyx","Parameters","--","--","--","--","--","lengths","The","length","of","the","sequences","in","the","input","data","sample",".","For","example",",","can","be","[","500",",","100",",","200","]",",","or","[","[","100",",","102","]",",","[","200",",","100","]",",","[","500",",","12","]","]","max_num_tokens","Max","number","of","tokens","of","each","batch","max_num_sentences","Max","number","of","sentences","of","each","batch","required_batch_size_multiple","Require","batch","size","to","be","a","multiple","of","N","(","default",":","1",")",".","This","will","generally","have","better","throughput","in","GPU",".","sort_type","The","way","we","sort","the","sample",".","-","sequential",":","We","sort","the","indices","based","on","the","individual","lengths",".","For","example",",","each","sample","has","(","src_length",",","tgt_length",")",".","We","will","sort","them","as","indices","=","indices","[","argsort","(","lengths","[",":",",","1","]",")","]","indices","=","indices","[","argsort","(","lengths","[",":",",","0","]",")","]","-","max",":","Take","the","max","of","the","lengths","and","sort","by","the","max","value",".","indices","=","indices","[","argsort","(","lengths.max","(","axis=-1",")","]","-","first",":","Just","sort","with","the","first","length","indices","=","indices","[","argsort","(","lengths","[",":",",","0","]","]","shuffle","Whether","to","shuffle","the","batches",".","seed","The","seed","of","the","sampler"]
code: def __len__(self):
      return len(self._batches)
  
imports: import math
  import random
  import warnings
  import numpy
  import abc
  import logging
  from typing import Union, Sequence, Optional, List
  from ..base import INT_TYPES
label_desc: Use image node_id 3 for calling the BoundedBudgetSampler obj's underlying member method code with example usage: obj.__len__() and returns: len