class_docstr: The ShaDow :math:`k`-hop sampler from the `"Decoupling the Depth and
  Scope of Graph Neural Networks" <https://arxiv.org/abs/2201.07858>`_ paper.
  Given a graph in a :obj:`data` object, the sampler will create shallow,
  localized subgraphs.
  A deep GNN on this local graph then smooths the informative local signals.
  
  .. note::
  
      For an example of using :class:`ShaDowKHopSampler`, see
      `examples/shadow.py <https://github.com/pyg-team/
      pytorch_geometric/blob/master/examples/shadow.py>`_.
  
  Args:
      data (torch_geometric.data.Data): The graph data object.
      depth (int): The depth/number of hops of the localized subgraph.
      num_neighbors (int): The number of neighbors to sample for each node in
          each hop.
      node_idx (LongTensor or BoolTensor, optional): The nodes that should be
          considered for creating mini-batches.
          If set to :obj:`None`, all nodes will be
          considered.
      replace (bool, optional): If set to :obj:`True`, will sample neighbors
          with replacement. (default: :obj:`False`)
      **kwargs (optional): Additional arguments of
          :class:`torch.utils.data.DataLoader`, such as :obj:`batch_size` or
          :obj:`num_workers`.
code: def __init__(
      self,
      data: Data,
      depth: int,
      num_neighbors: int,
      node_idx: Optional[Tensor] = None,
      replace: bool = False,
      **kwargs,
  ):
      if not WITH_TORCH_SPARSE:
          raise ImportError(
              f"'{self.__class__.__name__}' requires 'torch-sparse'"
          )
  
      self.data = copy.copy(data)
      self.depth = depth
      self.num_neighbors = num_neighbors
      self.replace = replace
  
      if data.edge_index is not None:
          self.is_sparse_tensor = False
          row, col = data.edge_index.cpu()
          self.adj_t = SparseTensor(
              row=row,
              col=col,
              value=torch.arange(col.size(0)),
              sparse_sizes=(data.num_nodes, data.num_nodes),
          ).t()
      else:
          self.is_sparse_tensor = True
          self.adj_t = data.adj_t.cpu()
  
      if node_idx is None:
          node_idx = torch.arange(self.adj_t.sparse_size(0))
      elif node_idx.dtype == torch.bool:
          node_idx = node_idx.nonzero(as_tuple=False).view(-1)
      self.node_idx = node_idx
  
      super().__init__(
          node_idx.tolist(), collate_fn=self.__collate__, **kwargs
      )
  
file_path: pytorch_geometric/torch_geometric/loader/shadow.py
imports: import copy
  from typing import Optional
  import torch
  from torch import Tensor
  from torch_geometric.data import Batch, Data
  from torch_geometric.typing import WITH_TORCH_SPARSE, SparseTensor
label_desc: Use image node_id 1 to create a new ShaDowKHopSampler object from inherited base classes: torch.utils.data with example: obj = ShaDowKHopSampler(data, depth, num_neighbors, node_idx, replace)