class_docstr: A simple subgraph loader that, given a pre-partioned :obj:`data` object,
  generates subgraphs from mini-batches in :obj:`ptr` (including their 1-hop
  neighbors).
class_docstr_tok: ["A","simple","subgraph","loader","that",",","given","a","pre-partioned",":","obj",":","`","data","`","object",",","generates","subgraphs","from","mini-batches","in",":","obj",":","`","ptr","`","(","including","their","1-hop","neighbors",")","."]
code: def compute_subgraph(
      self, batches: List[Tuple[int, Tensor]]
  ) -> SubData:
      batch_ids, n_ids = zip(*batches)
      n_id = torch.cat(n_ids, dim=0)
      batch_id = torch.tensor(batch_ids)
  
      # We collect the in-mini-batch size (`batch_size`), the offset of each
      # partition in the mini-batch (`offset`), and the number of nodes in
      # each partition (`count`)
      batch_size = n_id.numel()
      offset = self.ptr[batch_id]
      count = self.ptr[batch_id.add_(1)].sub_(offset)
  
      rowptr, col, value = self.data.adj_t.csr()
      rowptr, col, value, n_id = relabel_fn(
          rowptr, col, value, n_id, self.bipartite
      )
  
      adj_t = SparseTensor(
          rowptr=rowptr,
          col=col,
          value=value,
          sparse_sizes=(rowptr.numel() - 1, n_id.numel()),
          is_sorted=True,
      )
  
      data = self.data.__class__(adj_t=adj_t)
      for k, v in self.data:
          if isinstance(v, Tensor) and v.size(0) == self.data.num_nodes:
              data[k] = v.index_select(0, n_id)
  
      return SubData(data, batch_size, n_id, offset, count)
  
file_path: DIG/dig/lsgraph/method/GraphFMOB/loader.py
imports: from typing import NamedTuple, List, Tuple
  import time
  import torch
  from torch import Tensor
  from torch.utils.data import DataLoader
  from torch_sparse import SparseTensor
  from torch_geometric.data import Data
  from dig_ext.relabel import relabel_one_hop
label_desc: Use image node_id 2 for calling the SubgraphLoader obj's underlying member method code with example usage: obj.compute_subgraph(batches) and returns: SubData