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",">","`","."]
docstr: Find the list of MFGs necessary for computing the representation of given
  nodes for a node classification/regression task.
  
  Parameters
  ----------
  items : list[int] or list[tuple[str, int]]
      Either a list of node IDs (for homogeneous graphs), or a list of node type-ID
      pairs (for heterogeneous graphs).
  
  Returns
  -------
  input_nodes : Tensor or dict[ntype, Tensor]
      The input nodes necessary for computation in this minibatch.
  
      If the original graph has multiple node types, return a dictionary of
      node type names and node ID tensors.  Otherwise, return a single tensor.
  output_nodes : Tensor or dict[ntype, Tensor]
      The nodes whose representations are to be computed in this minibatch.
  
      If the original graph has multiple node types, return a dictionary of
      node type names and node ID tensors.  Otherwise, return a single tensor.
  MFGs : list[DGLGraph]
      The list of MFGs necessary for computing the representation.
docstr_tok: ["Find","the","list","of","MFGs","necessary","for","computing","the","representation","of","given","nodes","for","a","node","classification\/regression","task",".","Parameters","--","--","--","--","--","items",":","list","[","int","]","or","list","[","tuple","[","str",",","int","]","]","Either","a","list","of","node","IDs","(","for","homogeneous","graphs",")",",","or","a","list","of","node","type-ID","pairs","(","for","heterogeneous","graphs",")",".","Returns","--","--","--","-","input_nodes",":","Tensor","or","dict","[","ntype",",","Tensor","]","The","input","nodes","necessary","for","computation","in","this","minibatch",".","If","the","original","graph","has","multiple","node","types",",","return","a","dictionary","of","node","type","names","and","node","ID","tensors",".","Otherwise",",","return","a","single","tensor",".","output_nodes",":","Tensor","or","dict","[","ntype",",","Tensor","]","The","nodes","whose","representations","are","to","be","computed","in","this","minibatch",".","If","the","original","graph","has","multiple","node","types",",","return","a","dictionary","of","node","type","names","and","node","ID","tensors",".","Otherwise",",","return","a","single","tensor",".","MFGs",":","list","[","DGLGraph","]","The","list","of","MFGs","necessary","for","computing","the","representation","."]
code: def collate(self, items):
      """Find the list of MFGs necessary for computing the representation of given
      nodes for a node classification/regression task.
  
      Parameters
      ----------
      items : list[int] or list[tuple[str, int]]
          Either a list of node IDs (for homogeneous graphs), or a list of node type-ID
          pairs (for heterogeneous graphs).
  
      Returns
      -------
      input_nodes : Tensor or dict[ntype, Tensor]
          The input nodes necessary for computation in this minibatch.
  
          If the original graph has multiple node types, return a dictionary of
          node type names and node ID tensors.  Otherwise, return a single tensor.
      output_nodes : Tensor or dict[ntype, Tensor]
          The nodes whose representations are to be computed in this minibatch.
  
          If the original graph has multiple node types, return a dictionary of
          node type names and node ID tensors.  Otherwise, return a single tensor.
      MFGs : list[DGLGraph]
          The list of MFGs necessary for computing the representation.
      """
      if isinstance(items[0], tuple):
          # returns a list of pairs: group them by node types into a dict
          items = utils.group_as_dict(items)
      items = utils.prepare_tensor_or_dict(self.g, items, "items")
  
      (
          input_nodes,
          output_nodes,
          blocks,
      ) = self.graph_sampler.sample_blocks(self.g, items)
  
      return input_nodes, output_nodes, blocks
  
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 3 for calling the NodeCollator obj's underlying member method code with example usage: obj.collate(items) and returns: input_nodes,  output_nodes,  blocks