class_docstr: This sampler is built to work with a standard Pytorch ConcatDataset.
  
  It is used to retrieve elements from the different concatenated datasets placing them in the same batch
  with proportion specified by batch_sizes, e.g 8, 16 means each batch will
  be of 24 elements with the first 8 belonging to the first dataset in ConcatDataset
  object and the last 16 to the second.
  More than two datasets are supported, in that case you need to provide 3 batch
  sizes.
  
  Note
  ----
  Batched are drawn from the datasets till the one with smallest length is exhausted.
  Thus number of examples in your training epoch is dictated by the dataset
  whose length is the smallest.
  
  
  Arguments
  ---------
  samplers : list or tuple
      a list or tuple of pytorch samplers
  batch_sizes: list
      Batch sizes.
  epoch : int
      The epoch to start at.
  
  Example
  -------
  >>> import torch
  >>> from speechbrain.dataio.sampler import ConcatDatasetBatchSampler, ReproducibleRandomSampler
  >>> from speechbrain.dataio.sampler import ReproducibleRandomSampler
  >>> from speechbrain.dataio.dataloader import SaveableDataLoader
  >>> # example "datasets"
  >>> dataset1 = torch.arange(0, 10).unsqueeze(1)
  >>> dataset2 = torch.arange(20, 40).unsqueeze(1)
  >>> tot_dataset = torch.utils.data.ConcatDataset([dataset1, dataset2])
  >>> sampler1 = ReproducibleRandomSampler(dataset1)
  >>> sampler2 = ReproducibleRandomSampler(dataset2)
  >>> tot_sampler = ConcatDatasetBatchSampler([sampler1, sampler2], [2, 4])
  >>> dataloader = SaveableDataLoader(tot_dataset, batch_sampler = tot_sampler,
  ...     num_workers = 3)
  >>> for data_point in dataloader:
  ...      assert len(data_point) == 6
  ...      for i in range(2):
  ...         assert data_point[i] in [x for x in range(0, 10)]
  ...      for i in range(2, 4):
  ...         assert data_point[i] in [x for x in range(10, 40)]
class_docstr_tok: ["This","sampler","is","built","to","work","with","a","standard","Pytorch","ConcatDataset",".","It","is","used","to","retrieve","elements","from","the","different","concatenated","datasets","placing","them","in","the","same","batch","with","proportion","specified","by","batch_sizes",",","e.g","8",",","16","means","each","batch","will","be","of","24","elements","with","the","first","8","belonging","to","the","first","dataset","in","ConcatDataset","object","and","the","last","16","to","the","second",".","More","than","two","datasets","are","supported",",","in","that","case","you","need","to","provide","3","batch","sizes",".","Note","--","--","Batched","are","drawn","from","the","datasets","till","the","one","with","smallest","length","is","exhausted",".","Thus","number","of","examples","in","your","training","epoch","is","dictated","by","the","dataset","whose","length","is","the","smallest",".","Arguments","--","--","--","--","-","samplers",":","list","or","tuple","a","list","or","tuple","of","pytorch","samplers","batch_sizes",":","list","Batch","sizes",".","epoch",":","int","The","epoch","to","start","at",".","Example","--","--","--","-",">",">",">","import","torch",">",">",">","from","speechbrain.dataio.sampler","import","ConcatDatasetBatchSampler",",","ReproducibleRandomSampler",">",">",">","from","speechbrain.dataio.sampler","import","ReproducibleRandomSampler",">",">",">","from","speechbrain.dataio.dataloader","import","SaveableDataLoader",">",">",">","#","example","``","datasets","''",">",">",">","dataset1","=","torch.arange","(","0",",","10",")",".unsqueeze","(","1",")",">",">",">","dataset2","=","torch.arange","(","20",",","40",")",".unsqueeze","(","1",")",">",">",">","tot_dataset","=","torch.utils.data.ConcatDataset","(","[","dataset1",",","dataset2","]",")",">",">",">","sampler1","=","ReproducibleRandomSampler","(","dataset1",")",">",">",">","sampler2","=","ReproducibleRandomSampler","(","dataset2",")",">",">",">","tot_sampler","=","ConcatDatasetBatchSampler","(","[","sampler1",",","sampler2","]",",","[","2",",","4","]",")",">",">",">","dataloader","=","SaveableDataLoader","(","tot_dataset",",","batch_sampler","=","tot_sampler",",","...","num_workers","=","3",")",">",">",">","for","data_point","in","dataloader",":","...","assert","len","(","data_point",")","==","6","...","for","i","in","range","(","2",")",":","...","assert","data_point","[","i","]","in","[","x","for","x","in","range","(","0",",","10",")","]","...","for","i","in","range","(","2",",","4",")",":","...","assert","data_point","[","i","]","in","[","x","for","x","in","range","(","10",",","40",")","]"]
code: def __init__(
      self, samplers, batch_sizes: (tuple, list), epoch=0
  ) -> None:
      if not isinstance(samplers, (list, tuple)):
          raise ValueError(
              "samplers should be a list or tuple of Pytorch Samplers, "
              "but got samplers={}".format(samplers)
          )
  
      if not isinstance(batch_sizes, (list, tuple)):
          raise ValueError(
              "batch_sizes should be a list or tuple of integers, "
              "but got batch_sizes={}".format(batch_sizes)
          )
  
      if not len(batch_sizes) == len(samplers):
          raise ValueError(
              "batch_sizes and samplers should be have same length"
          )
  
      self.batch_sizes = batch_sizes
      self.samplers = samplers
      self.offsets = [0] + np.cumsum(
          [len(x) for x in self.samplers]
      ).tolist()[:-1]
  
      self.epoch = epoch
      self.set_epoch(self.epoch)
  
imports: import torch
  import logging
  from operator import itemgetter
  from torch.utils.data import RandomSampler, WeightedRandomSampler, DistributedSampler, Sampler
  import numpy
  from typing import List
  from speechbrain.dataio.dataset import DynamicItemDataset
  from collections import Counter
  from scipy.stats import lognorm
label_desc: Use image node_id 1 to create a new ConcatDatasetBatchSampler object from inherited base classes: Sampler with example: obj = ConcatDatasetBatchSampler(samplers, batch_sizes, epoch)