docstr: Sampler for WebDataset Urls with data parallelism.
  Args:
      urls : The urls of the tar files from which to sample.
      total_urls (int): Total number of urls in the dataset.
      chunk_size (int): Number of objects per tar file.
      consumed_samples (int): Number of samples consumed so far by the training process.
          **Note samples here is not urls.**
      data_parallel_rank (int): Rank of the current data parallel process.
      data_parallel_size (int): Number of data parallel processes.
      drop_last (bool): If True, drop the remaining urls if the number is smaller than `data_parallel_size`.
          If False, pad the urls until its size is divisible by `data_parallel_size`.
      data_sharding (bool): If True, use data sharding before data shuffling, i.e. only shuffle within the data parallel group.
docstr_tok: ["Sampler","for","WebDataset","Urls","with","data","parallelism",".","Args",":","urls",":","The","urls","of","the","tar","files","from","which","to","sample",".","total_urls","(","int",")",":","Total","number","of","urls","in","the","dataset",".","chunk_size","(","int",")",":","Number","of","objects","per","tar","file",".","consumed_samples","(","int",")",":","Number","of","samples","consumed","so","far","by","the","training","process",".","*","*","Note","samples","here","is","not","urls",".","*","*","data_parallel_rank","(","int",")",":","Rank","of","the","current","data","parallel","process",".","data_parallel_size","(","int",")",":","Number","of","data","parallel","processes",".","drop_last","(","bool",")",":","If","True",",","drop","the","remaining","urls","if","the","number","is","smaller","than","`","data_parallel_size","`",".","If","False",",","pad","the","urls","until","its","size","is","divisible","by","`","data_parallel_size","`",".","data_sharding","(","bool",")",":","If","True",",","use","data","sharding","before","data","shuffling",",","i.e",".","only","shuffle","within","the","data","parallel","group","."]
code: def __init__(
      self,
      urls,
      total_urls: int,
      chunk_size: int,
      consumed_samples: int,
      data_parallel_rank: int,
      data_parallel_size: int,
      num_workers: int,
      drop_last: bool,
      data_sharding: bool,
  ):
      r"""Sampler for WebDataset Urls with data parallelism.
      Args:
          urls : The urls of the tar files from which to sample.
          total_urls (int): Total number of urls in the dataset.
          chunk_size (int): Number of objects per tar file.
          consumed_samples (int): Number of samples consumed so far by the training process.
              **Note samples here is not urls.**
          data_parallel_rank (int): Rank of the current data parallel process.
          data_parallel_size (int): Number of data parallel processes.
          drop_last (bool): If True, drop the remaining urls if the number is smaller than `data_parallel_size`.
              If False, pad the urls until its size is divisible by `data_parallel_size`.
          data_sharding (bool): If True, use data sharding before data shuffling, i.e. only shuffle within the data parallel group.
      """
      super().__init__()
      self.urls = urls
      self.total_urls = total_urls
      self.chunk_size = chunk_size
  
      if consumed_samples % data_parallel_size == 0:
          logging.warning(
              "Multimodal data resuming will be approximate!"
          )
      self.consumed_urls = (
          consumed_samples
          // (data_parallel_size * num_workers)
          // chunk_size
          * (data_parallel_size * num_workers)
      )
      self.consumed_samples = self.consumed_urls * chunk_size
  
      self.data_parallel_rank = data_parallel_rank
      self.data_parallel_size = data_parallel_size
      self.drop_last = drop_last
      self.data_sharding = data_sharding
      self.epoch = SharedEpoch()
  
      self.remaining_urls = self.total_urls % self.data_parallel_size
  
file_path: NeMo/nemo/collections/multimodal/data/common/data_samplers.py
imports: from multiprocessing import Value
  import torch
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new WDSUrlsRandomSampler object from inherited base classes: IterableDataset with example: obj = WDSUrlsRandomSampler(urls, total_urls, chunk_size, consumed_samples, data_parallel_rank, data_parallel_size, num_workers, drop_last, data_sharding)