class_docstr: The neighbor sampler from the `"Inductive Representation Learning on
  Large Graphs" <https://arxiv.org/abs/1706.02216>`_ literature, which allows
  for mini-batch training of GNNs on large-scale graphs where full-batch
  training is not feasible.
  
  Arguments
  ------------
  edge_index:
      A :obj:`torch.LongTensor` that defines the underlying graph
      connectivity/message passing flow.
      :obj:`edge_index` holds the indices of a (sparse) adjacency matrix.
      If :obj:`edge_index` is of type :obj:`torch.LongTensor`, its shape
      must be defined as :obj:`[2, num_edges]`, where messages from nodes
      :obj:`edge_index[0]` are sent to nodes in :obj:`edge_index[1]`
      (in case :obj:`flow="source_to_target"`).
  target_nodes_indexes:
      indexes of target nodes to learn representation.
  sampling_sizes:
      The number of neighbors to sample for each node in each layer.
      If set to :obj:`sampling_sizes[l] = -1`, all neighbors are included in layer :obj:`l`.
  batch_size:
      number of target nodes for each mini-batch.
  num_workers:
      num_workers argument for inner :class:`torch.utils.data.DataLoader`
  shuffle:
      whether to shuffle target nodes for mini-batches.
code: def __init__(
      self,
      edge_index: torch.LongTensor,
      target_nodes_indexes: torch.LongTensor,
      sampling_sizes: _typing.Sequence[int],
      batch_size: int = 1,
      num_workers: int = 0,
      shuffle: bool = True,
      **kwargs,
  ):
      def is_deterministic(
          __cached: bool = bool(kwargs.get("cached", True))
      ) -> bool:
          if not __cached:
              return False
          _deterministic: bool = True
          for _sampling_size in sampling_sizes:
              if type(_sampling_size) != int:
                  raise TypeError(
                      "The sampling_sizes argument must be a sequence of integer"
                  )
              if _sampling_size >= 0:
                  _deterministic = False
                  break
          return _deterministic
  
      self.__edge_weight: torch.Tensor = self.__compute_edge_weight(
          edge_index
      )
      if int(torch_geometric.__version__.split(".")[0]) > 1:
          from torch_geometric.loader import NeighborSampler as NS
      else:
          from torch_geometric.data import NeighborSampler as NS
      self.__pyg_neighbor_sampler: NS = NS(
          edge_index,
          list(sampling_sizes[::-1]),
          target_nodes_indexes,
          transform=self._transform,
          batch_size=batch_size,
          num_workers=num_workers,
          shuffle=shuffle,
          **kwargs,
      )
  
      if is_deterministic():
          pyg_neighbor_sampler: _typing.Iterable = (
              self.__pyg_neighbor_sampler
          )
          self.__cached_sampled_data_list: _typing.Optional[
              _typing.List[TargetDependantSampledData]
          ] = [sampled_data for sampled_data in pyg_neighbor_sampler]
      else:
          self.__cached_sampled_data_list: _typing.Optional[
              _typing.List[TargetDependantSampledData]
          ] = None
  
file_path: AutoGL/autogl/module/train/sampling/sampler/neighbor_sampler.py
imports: import typing
  import torch.utils.data
  import torch_geometric
  from .target_dependant_sampler import TargetDependantSampler, TargetDependantSampledData
label_desc: Use image node_id 2 to create a new NeighborSampler object from inherited base classes: TargetDependantSampler, _typing with example: obj = NeighborSampler(edge_index, target_nodes_indexes, sampling_sizes, batch_size, num_workers, shuffle)