class_docstr: DGL collator to combine nodes and their computation dependencies within a minibatch for
  training node classification or regression on a single graph with neighborhood sampling.
  
  Parameters
  ----------
  g : DGLGraph
      The graph.
  nids : Tensor or dict[ntype, Tensor]
      The node set to compute outputs.
  graph_sampler : dgl.dataloading.BlockSampler
      The neighborhood sampler.
  
  Examples
  --------
  To train a 3-layer GNN for node classification on a set of nodes ``train_nid`` on
  a homogeneous graph where each node takes messages from all neighbors (assume
  the backend is PyTorch):
  
  >>> sampler = dgl.dataloading.MultiLayerNeighborSampler([15, 10, 5])
  >>> collator = dgl.dataloading.NodeCollator(g, train_nid, sampler)
  >>> dataloader = torch.utils.data.DataLoader(
  ...     collator.dataset, collate_fn=collator.collate,
  ...     batch_size=1024, shuffle=True, drop_last=False, num_workers=4)
  >>> for input_nodes, output_nodes, blocks in dataloader:
  ...     train_on(input_nodes, output_nodes, blocks)
  
  Notes
  -----
  For the concept of MFGs, please refer to
  :ref:`User Guide Section 6 <guide-minibatch>` and
  :doc:`Minibatch Training Tutorials <tutorials/large/L0_neighbor_sampling_overview>`.
class_docstr_tok: ["DGL","collator","to","combine","nodes","and","their","computation","dependencies","within","a","minibatch","for","training","node","classification","or","regression","on","a","single","graph","with","neighborhood","sampling",".","Parameters","--","--","--","--","--","g",":","DGLGraph","The","graph",".","nids",":","Tensor","or","dict","[","ntype",",","Tensor","]","The","node","set","to","compute","outputs",".","graph_sampler",":","dgl.dataloading.BlockSampler","The","neighborhood","sampler",".","Examples","--","--","--","--","To","train","a","3-layer","GNN","for","node","classification","on","a","set","of","nodes","``","train_nid","``","on","a","homogeneous","graph","where","each","node","takes","messages","from","all","neighbors","(","assume","the","backend","is","PyTorch",")",":",">",">",">","sampler","=","dgl.dataloading.MultiLayerNeighborSampler","(","[","15",",","10",",","5","]",")",">",">",">","collator","=","dgl.dataloading.NodeCollator","(","g",",","train_nid",",","sampler",")",">",">",">","dataloader","=","torch.utils.data.DataLoader","(","...","collator.dataset",",","collate_fn=collator.collate",",","...","batch_size=1024",",","shuffle=True",",","drop_last=False",",","num_workers=4",")",">",">",">","for","input_nodes",",","output_nodes",",","blocks","in","dataloader",":","...","train_on","(","input_nodes",",","output_nodes",",","blocks",")","Notes","--","--","-","For","the","concept","of","MFGs",",","please","refer","to",":","ref",":","`","User","Guide","Section","6","<","guide-minibatch",">","`","and",":","doc",":","`","Minibatch","Training","Tutorials","<","tutorials\/large\/L0_neighbor_sampling_overview",">","`","."]
code: def __init__(self, g, nids, graph_sampler):
      self.g = g
      if not isinstance(nids, Mapping):
          assert (
              len(g.ntypes) == 1
          ), "nids should be a dict of node type and ids for graph with multiple node types"
      self.graph_sampler = graph_sampler
  
      self.nids = utils.prepare_tensor_or_dict(g, nids, "nids")
      self._dataset = utils.maybe_flatten_dict(self.nids)
  
imports: import inspect
  from abc import ABC, abstractmethod, abstractproperty
  from collections.abc import Mapping
  from ..None import backend, transforms, utils
  from ..base import EID, NID
  from ..convert import heterograph
  from ..distributed import DistDataLoader
label_desc: Use image node_id 1 to create a new NodeCollator object from inherited base classes: Collator with example: obj = NodeCollator(g, nids, graph_sampler)