original_docstring: Makes a basic DataLoader with SpeechBrain defaults.
  
      For DynamicItemDatasets (which return dicts), use
      PaddedBatch as the default collate_fn.
  
      Shuffling gets implemented by ReproducibleRandomSampler.
  
      If the Dataset is not an IterableDataset, the DataLoader
      is a SaveableDataLoader.
  
      If the Dataset is a webdataset.dataset.Composable, set default
      batch_size = None.
  
      Can also loop over the underlying dataloader continuously,
      and stop iterations at nominal epoch lengths.
  
      Arguments
      ---------
      dataset : Dataset
          The dataset to make a DataLoader for.
      looped_nominal_epoch : None, int
          If an integer is given, loop the underlying DataLoader infinitely and
          set a nominal epoch length in batches (or whatever the DataLoader
          yields).
      **loader_kwargs : dict
          Keyword args to DataLoader, see PyTorch DataLoader for
          options.
  
      Returns
      -------
      DataLoader
          If looped_nominal_epoch is None
      LoopedLoader
          If looped_nominal_epoch is not None
      
docstring: Makes a basic DataLoader with SpeechBrain defaults.
  For DynamicItemDatasets (which return dicts), use
  PaddedBatch as the default collate_fn.
  
  Shuffling gets implemented by ReproducibleRandomSampler.
  
  If the Dataset is not an IterableDataset, the DataLoader
  is a SaveableDataLoader.
  
  If the Dataset is a webdataset.dataset.Composable, set default
  batch_size = None.
  
  Can also loop over the underlying dataloader continuously,
  and stop iterations at nominal epoch lengths.
  
  Arguments
  
  dataset : Dataset
  The dataset to make a DataLoader for.
  looped_nominal_epoch : None, int
  If an integer is given, loop the underlying DataLoader infinitely and
  set a nominal epoch length in batches (or whatever the DataLoader
  yields).
  
  Returns
  
  
docstring_tokens: Makes a basic DataLoader with SpeechBrain defaults . For DynamicItemDatasets ( which return dicts ) use PaddedBatch as the default collate_fn . Shuffling gets implemented by ReproducibleRandomSampler . If the Dataset is not an IterableDataset the DataLoader is a SaveableDataLoader . If the Dataset is a webdataset . dataset . Composable set default batch_size = None . Can also loop over the underlying dataloader continuously and stop iterations at nominal epoch lengths . Arguments dataset : Dataset The dataset to make a DataLoader for . looped_nominal_epoch : None int If an integer is given loop the underlying DataLoader infinitely and set a nominal epoch length in batches ( or whatever the DataLoader yields ) . Returns
code: def make_dataloader(dataset, looped_nominal_epoch=None, **loader_kwargs):
      """Makes a basic DataLoader with SpeechBrain defaults.
  
      For DynamicItemDatasets (which return dicts), use
      PaddedBatch as the default collate_fn.
  
      Shuffling gets implemented by ReproducibleRandomSampler.
  
      If the Dataset is not an IterableDataset, the DataLoader
      is a SaveableDataLoader.
  
      If the Dataset is a webdataset.dataset.Composable, set default
      batch_size = None.
  
      Can also loop over the underlying dataloader continuously,
      and stop iterations at nominal epoch lengths.
  
      Arguments
      ---------
      dataset : Dataset
          The dataset to make a DataLoader for.
      looped_nominal_epoch : None, int
          If an integer is given, loop the underlying DataLoader infinitely and
          set a nominal epoch length in batches (or whatever the DataLoader
          yields).
      **loader_kwargs : dict
          Keyword args to DataLoader, see PyTorch DataLoader for
          options.
  
      Returns
      -------
      DataLoader
          If looped_nominal_epoch is None
      LoopedLoader
          If looped_nominal_epoch is not None
      """
      # PaddedBatch as default collation for DynamicItemDataset
      if "collate_fn" not in loader_kwargs and isinstance(
          dataset, DynamicItemDataset
      ):
          loader_kwargs["collate_fn"] = PaddedBatch
      # Reproducible random sampling
      if loader_kwargs.get("shuffle", False):
          if loader_kwargs.get("sampler") is not None:
              raise ValueError(
                  "Cannot specify both shuffle=True and a "
                  "sampler in loader_kwargs"
              )
          sampler = ReproducibleRandomSampler(dataset)
          loader_kwargs["sampler"] = sampler
          # Should delete shuffle because you can't set both Sampler and
          # shuffle
          # NOTE: the dict of loader options may get used elsewhere!
          # However, this del doesn't touch those because loader_kwargs comes
          # from a **kwargs dict.
          del loader_kwargs["shuffle"]
      # With WDS it is recommended to do batching in the dataset itself,
      # which requires batch_size = None in the DataLoader
      if (
          WDS_AVAILABLE
          and isinstance(dataset, wds.dataset.Composable)
          and "batch_size" not in loader_kwargs
      ):
          loader_kwargs["batch_size"] = None
      # Create the loader
      if isinstance(dataset, IterableDataset):
          dataloader = DataLoader(dataset, **loader_kwargs)
      else:
          dataloader = SaveableDataLoader(dataset, **loader_kwargs)
      if looped_nominal_epoch is not None:
          dataloader = LoopedLoader(dataloader, looped_nominal_epoch)
      return dataloader
code_tokens: def make_dataloader ( dataset , looped_nominal_epoch = None , ** loader_kwargs ) : if "collate_fn" not in loader_kwargs and isinstance ( dataset , DynamicItemDataset ) : loader_kwargs [ "collate_fn" ] = PaddedBatch if loader_kwargs . get ( "shuffle" , False ) : if loader_kwargs . get ( "sampler" ) is not None : raise ValueError ( "Cannot specify both shuffle=True and a " "sampler in loader_kwargs" ) sampler = ReproducibleRandomSampler ( dataset ) loader_kwargs [ "sampler" ] = sampler del loader_kwargs [ "shuffle" ] if ( WDS_AVAILABLE and isinstance ( dataset , wds . dataset . Composable ) and "batch_size" not in loader_kwargs ) : loader_kwargs [ "batch_size" ] = None if isinstance ( dataset , IterableDataset ) : dataloader = DataLoader ( dataset , ** loader_kwargs ) else : dataloader = SaveableDataLoader ( dataset , ** loader_kwargs ) if looped_nominal_epoch is not None : dataloader = LoopedLoader ( dataloader , looped_nominal_epoch ) return dataloader
short_docstring: Makes a basic DataLoader with SpeechBrain defaults.
short_docstring_tokens: Makes a basic DataLoader with SpeechBrain defaults .
comment: """Makes a basic DataLoader with SpeechBrain defaults.
  
      For DynamicItemDatasets (which return dicts), use
      PaddedBatch as the default collate_fn.
  
      Shuffling gets implemented by ReproducibleRandomSampler.
  
      If the Dataset is not an IterableDataset, the DataLoader
      is a SaveableDataLoader.
  
      If the Dataset is a webdataset.dataset.Composable, set default
      batch_size = None.
  
      Can also loop over the underlying dataloader continuously,
      and stop iterations at nominal epoch lengths.
  
      Arguments
      ---------
      dataset : Dataset
          The dataset to make a DataLoader for.
      looped_nominal_epoch : None, int
          If an integer is given, loop the underlying DataLoader infinitely and
          set a nominal epoch length in batches (or whatever the DataLoader
          yields).
      **loader_kwargs : dict
          Keyword args to DataLoader, see PyTorch DataLoader for
          options.
  
      Returns
      -------
      DataLoader
          If looped_nominal_epoch is None
      LoopedLoader
          If looped_nominal_epoch is not None
      """$SEP$# PaddedBatch as default collation for DynamicItemDataset$SEP$# Reproducible random sampling$SEP$# Should delete shuffle because you can't set both Sampler and$SEP$# shuffle$SEP$# NOTE: the dict of loader options may get used elsewhere!$SEP$# However, this del doesn't touch those because loader_kwargs comes$SEP$# from a **kwargs dict.$SEP$# With WDS it is recommended to do batching in the dataset itself,$SEP$# which requires batch_size = None in the DataLoader$SEP$# Create the loader