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: Called in from_data_list to collate a dictionary.
  This can also be applied to Graph object, since it has support for
  keys and __getitem__().
  
  Args:
      curr_dict: current dictionary to be added to the
          collated dictionary.
      cumsum: cumulative sum to be used for indexing.
      slices: a dictionary of the same structure as batched_dict,
          slices[key] indicates the indices to slice batch[key] into
          tensors for all graphs in the batch.
      batched_dict: the batched dictionary of the same structure
          as curr_dict. But all graph data are batched together.
docstr_tok: ["Called","in","from_data_list","to","collate","a","dictionary",".","This","can","also","be","applied","to","Graph","object",",","since","it","has","support","for","keys","and","__getitem__","(",")",".","Args",":","curr_dict",":","current","dictionary","to","be","added","to","the","collated","dictionary",".","cumsum",":","cumulative","sum","to","be","used","for","indexing",".","slices",":","a","dictionary","of","the","same","structure","as","batched_dict",",","slices","[","key","]","indicates","the","indices","to","slice","batch","[","key","]","into","tensors","for","all","graphs","in","the","batch",".","batched_dict",":","the","batched","dictionary","of","the","same","structure","as","curr_dict",".","But","all","graph","data","are","batched","together","."]
code: def _collate_dict(
      curr_dict,
      cumsum: Dict[str, int],
      slices,
      batched_dict,
      graph,
      follow_batch,
      i=None,
  ):
      r"""Called in from_data_list to collate a dictionary.
      This can also be applied to Graph object, since it has support for
      keys and __getitem__().
  
      Args:
          curr_dict: current dictionary to be added to the
              collated dictionary.
          cumsum: cumulative sum to be used for indexing.
          slices: a dictionary of the same structure as batched_dict,
              slices[key] indicates the indices to slice batch[key] into
              tensors for all graphs in the batch.
          batched_dict: the batched dictionary of the same structure
              as curr_dict. But all graph data are batched together.
      """
      if isinstance(curr_dict, dict):
          keys = curr_dict.keys()
      else:
          keys = curr_dict.keys
      for key in keys:
          item = curr_dict[key]
          if isinstance(item, dict):
              # recursively collate every key in the dictionary
              if isinstance(batched_dict[key], list):
                  # nested dictionary not initialized yet
                  assert len(batched_dict[key]) == 0
                  # initialize the nested dictionary for batch
                  cumsum[key] = {
                      inner_key: 0 for inner_key in item.keys()
                  }
                  slices[key] = {
                      inner_key: [0] for inner_key in item.keys()
                  }
                  batched_dict[key] = {}
                  for inner_key in item.keys():
                      batched_dict[key][inner_key] = []
                  for inner_key in follow_batch:
                      batched_dict[key][f"{key}_batch"] = []
              Batch._collate_dict(
                  item,
                  cumsum[key],
                  slices[key],
                  batched_dict[key],
                  graph,
                  follow_batch,
                  i=i,
              )
              continue
          if torch.is_tensor(item) and item.dtype != torch.bool:
              item = item + cumsum[key]
          if torch.is_tensor(item):
              size = item.size(graph.__cat_dim__(key, curr_dict[key]))
          else:
              size = 1
          slices[key].append(size + slices[key][-1])
          cumsum[key] = cumsum[key] + graph.__inc__(key, item)
          batched_dict[key].append(item)
  
          if key in follow_batch:
              item = torch.full((size,), i, dtype=torch.long)
              batched_dict[f"{key}_batch"].append(item)
  
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 5 for calling the Batch obj's underlying member method code with example usage: obj._collate_dict(curr_dict, cumsum, slices, batched_dict, graph, follow_batch, i) without return types