class_docstr: Description
  -----------
  SAINTSampler implements the sampler described in GraphSAINT. This sampler implements offline sampling in
  pre-sampling phase as well as fully offline sampling, fully online sampling in training phase.
  Users can conveniently set param 'online' of the sampler to choose different modes.
  
  Parameters
  ----------
  node_budget : int
      the expected number of nodes in each subgraph, which is specifically explained in the paper. Actually this
      param specifies the times of sampling nodes from the original graph with replacement. The meaning of edge_budget
      is similar to the node_budget.
  dn : str
      name of dataset.
  g : DGLGraph
      the full graph.
  train_nid : list
      ids of training nodes.
  num_workers_sampler : int
      number of processes to sample subgraphs in pre-sampling procedure using torch.dataloader.
  num_subg_sampler : int, optional
      the max number of subgraphs sampled in pre-sampling phase for computing normalization coefficients in the beginning.
      Actually this param is used as ``__len__`` of sampler in pre-sampling phase.
      Please make sure that num_subg_sampler is greater than batch_size_sampler so that we can sample enough subgraphs.
      Defaults: 10000
  batch_size_sampler : int, optional
      the number of subgraphs sampled by each process concurrently in pre-sampling phase.
      Defaults: 200
  online : bool, optional
      If `True`, we employ online sampling in training phase. Otherwise employing offline sampling.
      Defaults: True
  num_subg : int, optional
      the expected number of sampled subgraphs in pre-sampling phase.
      It is actually the 'N' in the original paper. Note that this param is different from the num_subg_sampler.
      This param is just used to control the number of pre-sampled subgraphs.
      Defaults: 50
  full : bool, optional
      True if the number of subgraphs used in the training phase equals to that of pre-sampled subgraphs, or
      ``math.ceil(self.train_g.num_nodes() / self.node_budget)``. This formula takes the result of A divided by B as
      the number of subgraphs used in the training phase, where A is the number of training nodes in the original
      graph, B is the expected number of nodes in each pre-sampled subgraph. Please refer to the paper to check the
      details.
      Defaults: True
  
  Notes
  -----
  For parallelism of pre-sampling, we utilize `torch.DataLoader` to concurrently speed up sampling.
  The `num_subg_sampler` is the return value of `__len__` in pre-sampling phase. Moreover, the param `batch_size_sampler`
  determines the batch_size of `torch.DataLoader` in internal pre-sampling part. But note that if we wanna pass the
  SAINTSampler to `torch.DataLoader` for concurrently sampling subgraphs in training phase, we need to specify
  `batch_size` of `DataLoader`, that is, `batch_size_sampler` is not related to how sampler works in training procedure.
class_docstr_tok: ["Description","--","--","--","--","--","-","SAINTSampler","implements","the","sampler","described","in","GraphSAINT",".","This","sampler","implements","offline","sampling","in","pre-sampling","phase","as","well","as","fully","offline","sampling",",","fully","online","sampling","in","training","phase",".","Users","can","conveniently","set","param","'online","'","of","the","sampler","to","choose","different","modes",".","Parameters","--","--","--","--","--","node_budget",":","int","the","expected","number","of","nodes","in","each","subgraph",",","which","is","specifically","explained","in","the","paper",".","Actually","this","param","specifies","the","times","of","sampling","nodes","from","the","original","graph","with","replacement",".","The","meaning","of","edge_budget","is","similar","to","the","node_budget",".","dn",":","str","name","of","dataset",".","g",":","DGLGraph","the","full","graph",".","train_nid",":","list","ids","of","training","nodes",".","num_workers_sampler",":","int","number","of","processes","to","sample","subgraphs","in","pre-sampling","procedure","using","torch.dataloader",".","num_subg_sampler",":","int",",","optional","the","max","number","of","subgraphs","sampled","in","pre-sampling","phase","for","computing","normalization","coefficients","in","the","beginning",".","Actually","this","param","is","used","as","``","__len__","``","of","sampler","in","pre-sampling","phase",".","Please","make","sure","that","num_subg_sampler","is","greater","than","batch_size_sampler","so","that","we","can","sample","enough","subgraphs",".","Defaults",":","10000","batch_size_sampler",":","int",",","optional","the","number","of","subgraphs","sampled","by","each","process","concurrently","in","pre-sampling","phase",".","Defaults",":","200","online",":","bool",",","optional","If","`","True","`",",","we","employ","online","sampling","in","training","phase",".","Otherwise","employing","offline","sampling",".","Defaults",":","True","num_subg",":","int",",","optional","the","expected","number","of","sampled","subgraphs","in","pre-sampling","phase",".","It","is","actually","the","'N","'","in","the","original","paper",".","Note","that","this","param","is","different","from","the","num_subg_sampler",".","This","param","is","just","used","to","control","the","number","of","pre-sampled","subgraphs",".","Defaults",":","50","full",":","bool",",","optional","True","if","the","number","of","subgraphs","used","in","the","training","phase","equals","to","that","of","pre-sampled","subgraphs",",","or","``","math.ceil","(","self.train_g.num_nodes","(",")","\/","self.node_budget",")","``",".","This","formula","takes","the","result","of","A","divided","by","B","as","the","number","of","subgraphs","used","in","the","training","phase",",","where","A","is","the","number","of","training","nodes","in","the","original","graph",",","B","is","the","expected","number","of","nodes","in","each","pre-sampled","subgraph",".","Please","refer","to","the","paper","to","check","the","details",".","Defaults",":","True","Notes","--","--","-","For","parallelism","of","pre-sampling",",","we","utilize","`","torch.DataLoader","`","to","concurrently","speed","up","sampling",".","The","`","num_subg_sampler","`","is","the","return","value","of","`","__len__","`","in","pre-sampling","phase",".","Moreover",",","the","param","`","batch_size_sampler","`","determines","the","batch_size","of","`","torch.DataLoader","`","in","internal","pre-sampling","part",".","But","note","that","if","we","wan","na","pass","the","SAINTSampler","to","`","torch.DataLoader","`","for","concurrently","sampling","subgraphs","in","training","phase",",","we","need","to","specify","`","batch_size","`","of","`","DataLoader","`",",","that","is",",","`","batch_size_sampler","`","is","not","related","to","how","sampler","works","in","training","procedure","."]
code: def __getitem__(self, idx):
      # Only when sampling subgraphs in training procedure and need to utilize sampled subgraphs and we still
      # have sampled subgraphs we can fetch a subgraph from sampled subgraphs
      if self.train:
          if self.online:
              subgraph = self.__sample__()
              return dgl.node_subgraph(self.train_g, subgraph)
          else:
              return dgl.node_subgraph(
                  self.train_g, self.subgraphs[idx]
              )
      else:
          subgraph_nids = self.__sample__()
          num_nodes = len(subgraph_nids)
          subgraph_eids = dgl.node_subgraph(
              self.train_g, subgraph_nids
          ).edata[dgl.EID]
          return num_nodes, subgraph_nids, subgraph_eids
  
imports: import math
  import os
  import random
  import time
  import dgl
  import dgl.function
  import numpy
  import scipy
  import torch
  from dgl.sampling import pack_traces, random_walk
  from torch.utils.data import DataLoader
label_desc: Use image node_id 3 for calling the SAINTSampler obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: num_nodes,  subgraph_nids,  subgraph_eids, dgl, dgl