class_docstr: A modified version of the PyTorch DataLoader that returns a dictionary where the key is
  the name of the tensor and the value is the tensor itself.
docstr: :param dataset: The dataset that will be wrapped by this NamedDataLoader
  :type dataset: Dataset
  :param sampler: The sampler used by the NamedDataLoader to choose which samples to include in the batch
  :type sampler: Sampler
  :param batch_size: The size of the batch to be returned by the NamedDataLoader
  :type batch_size: int
  :param tensor_names: The names of the tensor, in the order that the dataset returns them in.
  :type tensor_names: list
  :param num_workers: number of workers to use for the DataLoader
  :type num_workers: int
  :param pin_memory: argument for Data Loader to use page-locked memory for faster transfer of data to GPU
  :type pin_memory: bool
docstr_tok: [":","param","dataset",":","The","dataset","that","will","be","wrapped","by","this","NamedDataLoader",":","type","dataset",":","Dataset",":","param","sampler",":","The","sampler","used","by","the","NamedDataLoader","to","choose","which","samples","to","include","in","the","batch",":","type","sampler",":","Sampler",":","param","batch_size",":","The","size","of","the","batch","to","be","returned","by","the","NamedDataLoader",":","type","batch_size",":","int",":","param","tensor_names",":","The","names","of","the","tensor",",","in","the","order","that","the","dataset","returns","them","in",".",":","type","tensor_names",":","list",":","param","num_workers",":","number","of","workers","to","use","for","the","DataLoader",":","type","num_workers",":","int",":","param","pin_memory",":","argument","for","Data","Loader","to","use","page-locked","memory","for","faster","transfer","of","data","to","GPU",":","type","pin_memory",":","bool"]
code: def __init__(
      self,
      dataset,
      batch_size,
      sampler=None,
      tensor_names=None,
      num_workers=0,
      pin_memory=False,
  ):
      """
      :param dataset: The dataset that will be wrapped by this NamedDataLoader
      :type dataset: Dataset
      :param sampler: The sampler used by the NamedDataLoader to choose which samples to include in the batch
      :type sampler: Sampler
      :param batch_size: The size of the batch to be returned by the NamedDataLoader
      :type batch_size: int
      :param tensor_names: The names of the tensor, in the order that the dataset returns them in.
      :type tensor_names: list
      :param num_workers: number of workers to use for the DataLoader
      :type num_workers: int
      :param pin_memory: argument for Data Loader to use page-locked memory for faster transfer of data to GPU
      :type pin_memory: bool
      """
  
      def collate_fn(batch):
          """
          A custom collate function that formats the batch as a dictionary where the key is
          the name of the tensor and the value is the tensor itself
          """
  
          if type(dataset).__name__ == "_StreamingDataSet":
              _tensor_names = dataset.tensor_names
          else:
              _tensor_names = tensor_names
  
          if type(batch[0]) == list:
              batch = batch[0]
  
          assert len(batch[0]) == len(
              _tensor_names
          ), "Dataset contains {} tensors while there are {} tensor names supplied: {}".format(
              len(batch[0]), len(_tensor_names), _tensor_names
          )
          lists_temp = [[] for _ in range(len(_tensor_names))]
          ret = dict(zip(_tensor_names, lists_temp))
  
          for example in batch:
              for name, tensor in zip(_tensor_names, example):
                  ret[name].append(tensor)
  
          for key in ret:
              ret[key] = torch.stack(ret[key])
  
          return ret
  
      super(NamedDataLoader, self).__init__(
          dataset=dataset,
          sampler=sampler,
          batch_size=batch_size,
          collate_fn=collate_fn,
          pin_memory=pin_memory,
          num_workers=num_workers,
      )
  
imports: from math import ceil
  from torch.utils.data import DataLoader, Dataset, Sampler
  import torch
label_desc: Use image node_id 1 to create a new NamedDataLoader object from inherited base classes: DataLoader with example: obj = NamedDataLoader(dataset, batch_size, sampler, tensor_names, num_workers, pin_memory)