class_docstr: A plain old python object modeling a batch of
  :class:`deepsnap.graph.Graph` objects as one big (disconnected) graph,
  with :class:`torch_geometric.data.Data` being the
  base class that all its methods can also be used here.
  In addition, graphs can be reconstructed via the assignment vector
  :obj:`batch`, which maps each node to its respective graph identifier.
  
  .. note::
  
      For more detailed use of :class:`deepsnap.batch.Batch`, see the `examples 
      <https://github.com/snap-stanford/deepsnap/tree/master/examples>`_ folder.
class_docstr_tok: ["A","plain","old","python","object","modeling","a","batch","of",":","class",":","`","deepsnap.graph.Graph","`","objects","as","one","big","(","disconnected",")","graph",",","with",":","class",":","`","torch_geometric.data.Data","`","being","the","base","class","that","all","its","methods","can","also","be","used","here",".","In","addition",",","graphs","can","be","reconstructed","via","the","assignment","vector",":","obj",":","`","batch","`",",","which","maps","each","node","to","its","respective","graph","identifier",".","..","note",":",":","For","more","detailed","use","of",":","class",":","`","deepsnap.batch.Batch","`",",","see","the","`","examples","<","https",":","\/\/github.com\/snap-stanford\/deepsnap\/tree\/master\/examples",">","`","_","folder","."]
docstr: Constructs A :class:`deepsnap.batch.Batch` object from a python list
  holding :class:`torch_geometric.data.Data` objects.
  The assignment vector :obj:`batch` is created on the fly.
  Additionally, creates assignment batch vectors for each key in
  :obj:`follow_batch`.
  
  Args:
      data_list (list): A list of :class:`deepsnap.graph.Graph` objects.
      follow_batch (list): Creates assignment batch vectors
          for each key.
      transform (callable): If it is not `None`, apply transform 
          when batching.
      **kwargs: Other parameters.
docstr_tok: ["Constructs","A",":","class",":","`","deepsnap.batch.Batch","`","object","from","a","python","list","holding",":","class",":","`","torch_geometric.data.Data","`","objects",".","The","assignment","vector",":","obj",":","`","batch","`","is","created","on","the","fly",".","Additionally",",","creates","assignment","batch","vectors","for","each","key","in",":","obj",":","`","follow_batch","`",".","Args",":","data_list","(","list",")",":","A","list","of",":","class",":","`","deepsnap.graph.Graph","`","objects",".","follow_batch","(","list",")",":","Creates","assignment","batch","vectors","for","each","key",".","transform","(","callable",")",":","If","it","is","not","`","None","`",",","apply","transform","when","batching",".","*","*","kwargs",":","Other","parameters","."]
code: def from_data_list(
      data_list: List[Graph],
      follow_batch: List = None,
      transform: Callable = None,
      **kwargs,
  ):
      r"""
      Constructs A :class:`deepsnap.batch.Batch` object from a python list
      holding :class:`torch_geometric.data.Data` objects.
      The assignment vector :obj:`batch` is created on the fly.
      Additionally, creates assignment batch vectors for each key in
      :obj:`follow_batch`.
  
      Args:
          data_list (list): A list of :class:`deepsnap.graph.Graph` objects.
          follow_batch (list): Creates assignment batch vectors
              for each key.
          transform (callable): If it is not `None`, apply transform
              when batching.
          **kwargs: Other parameters.
      """
      if follow_batch is None:
          follow_batch = []
      if transform is not None:
          data_list = [
              data.apply_transform(
                  transform,
                  deep_copy=True,
                  **kwargs,
              )
              for data in data_list
          ]
      keys = [set(data.keys) for data in data_list]
      keys = list(set.union(*keys))
      assert "batch" not in keys
  
      batch, cumsum = Batch._init_batch_fields(keys, follow_batch)
      batch.__data_class__ = data_list[0].__class__
      batch.batch = []
      for i, data in enumerate(data_list):
          # Note: in heterogeneous graph, __inc__ logic is different
          Batch._collate_dict(
              data,
              cumsum,
              batch.__slices__,
              batch,
              data,
              follow_batch,
              i=i,
          )
          if isinstance(data, Graph):
              if isinstance(data, HeteroGraph):
                  num_nodes = sum(data.num_nodes().values())
              else:
                  num_nodes = data.num_nodes
          else:
              raise TypeError(
                  "element in self.graphs of unexpected type"
              )
          if num_nodes is not None:
              item = torch.full((num_nodes,), i, dtype=torch.long)
              batch.batch.append(item)
  
      if num_nodes is None:
          batch.batch = None
  
      Batch._dict_list_to_tensor(batch, data_list[0])
  
      return batch.contiguous()
  
file_path: deepsnap/deepsnap/batch.py
imports: import torch
  from deepsnap.graph import Graph
  from deepsnap.hetero_graph import HeteroGraph
  from typing import Callable, Dict, List
label_desc: Use image node_id 3 for calling the Batch obj's underlying member method code with example usage: obj.from_data_list(data_list, follow_batch, transform) and returns: batch