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 __init__(
      self,
      data: Data,
      ptr: Tensor,
      batch_size: int = 1,
      bipartite: bool = True,
      log: bool = True,
      **kwargs,
  ):
      self.data = data
      self.ptr = ptr
      self.bipartite = bipartite
      self.log = log
  
      n_id = torch.arange(data.num_nodes)
      batches = n_id.split((ptr[1:] - ptr[:-1]).tolist())
      batches = [(i, batches[i]) for i in range(len(batches))]
  
      if batch_size > 1:
          super().__init__(
              batches,
              batch_size=batch_size,
              collate_fn=self.compute_subgraph,
              **kwargs,
          )
  
      else:  # If `batch_size=1`, we pre-process the subgraph generation:
          if log:
              t = time.perf_counter()
              print("Pre-processing subgraphs...", end=" ", flush=True)
  
          data_list = list(
              DataLoader(
                  batches,
                  collate_fn=self.compute_subgraph,
                  batch_size=batch_size,
                  **kwargs,
              )
          )
  
          if log:
              print(f"Done! [{time.perf_counter() - t:.2f}s]")
  
          super().__init__(
              data_list,
              batch_size=batch_size,
              collate_fn=lambda x: x[0],
              **kwargs,
          )
  
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 1 to create a new SubgraphLoader object from inherited base classes: DataLoader with example: obj = SubgraphLoader(data, ptr, batch_size, bipartite, log)