class_docstr: Dataset Split Manager. Possess train/valid/test datasets and provide data loaders
  
  Parameters:
  --------------
  train_set: torch.utils.data.Dataset
      training dataset
  valid_set: torch.utils.data.Dataset or None
      validation dataset if provided
  test_set: torch.utils.data.Dataset
      test dataset
  collate_fn: callable
      function that accepts a batch of inputs and
      returns a stacked version for each data field
  always_validation: bool
      if True, use test data at request of validation loader;
      otherwise return None
class_docstr_tok: ["Dataset","Split","Manager",".","Possess","train\/valid\/test","datasets","and","provide","data","loaders","Parameters",":","--","--","--","--","--","--","--","train_set",":","torch.utils.data.Dataset","training","dataset","valid_set",":","torch.utils.data.Dataset","or","None","validation","dataset","if","provided","test_set",":","torch.utils.data.Dataset","test","dataset","collate_fn",":","callable","function","that","accepts","a","batch","of","inputs","and","returns","a","stacked","version","for","each","data","field","always_validation",":","bool","if","True",",","use","test","data","at","request","of","validation","loader",";","otherwise","return","None"]
code: def _data_loader(
      self,
      dataset: Dataset,
      batch_size: int,
      shuffle: bool,
      cuda_device: int,
      is_training: bool,
      n_workers: int,
      n_batches: Optional[int],
  ) -> Iterator:
      if is_distributed() and is_training:
          sampler = DistributedSampler(dataset, shuffle=shuffle)
          batch_size //= get_world_size()
          shuffle = False
      else:
          sampler = None
      loader = DataLoader(
          dataset,
          batch_size=batch_size,
          shuffle=shuffle,
          sampler=sampler,
          num_workers=n_workers,
          collate_fn=self.collate_fn,
          pin_memory=cuda_device >= 0,
          drop_last=n_batches is not None,
      )
      if n_batches is None:
          n_batches = len(loader)
      iterator = iter(loader)
      for batch in range(n_batches):
          try:
              data = next(iterator)
          except StopIteration:
              iterator = iter(loader)
              data = next(iterator)
          if cuda_device >= 0:
              data = copy_to_gpu(data, cuda_device, non_blocking=True)
          yield data
  
file_path: gluonts/src/gluonts/nursery/daf/tslib/dataset/loader.py
imports: from typing import NamedTuple, Callable, Optional, Iterator
  import re
  from torch import Tensor
  from torch._six import container_abcs, int_classes, string_classes
  from torch.utils.data import Dataset, DataLoader, DistributedSampler
  import torch
  from ..engine.distributed import is_distributed, get_world_size
label_desc: Use image node_id 5 for calling the MetaDataset obj's underlying member method code with example usage: obj._data_loader(dataset, batch_size, shuffle, cuda_device, is_training, n_workers, n_batches) without return types