code: def test_neighbor_sampler_on_cora(get_dataset):
      dataset = get_dataset(name="Cora")
      data = dataset[0]
  
      batch = torch.arange(10)
      loader = NeighborSampler(
          data.edge_index,
          sizes=[-1, -1, -1],
          node_idx=batch,
          batch_size=10,
      )
  
      class SAGE(torch.nn.Module):
          def __init__(self, in_channels, out_channels):
              super().__init__()
  
              self.convs = torch.nn.ModuleList()
              self.convs.append(SAGEConv(in_channels, 16))
              self.convs.append(SAGEConv(16, 16))
              self.convs.append(SAGEConv(16, out_channels))
  
          def batch(self, x, adjs):
              for i, (edge_index, _, size) in enumerate(adjs):
                  x_target = x[
                      : size[1]
                  ]  # Target nodes are always placed first.
                  x = self.convs[i]((x, x_target), edge_index)
              return x
  
          def full(self, x, edge_index):
              for conv in self.convs:
                  x = conv(x, edge_index)
              return x
  
      model = SAGE(dataset.num_features, dataset.num_classes)
  
      _, n_id, adjs = next(iter(loader))
      out1 = model.batch(data.x[n_id], adjs)
      out2 = model.full(data.x, data.edge_index)[batch]
      assert torch.allclose(out1, out2, atol=1e-7)
  
      class GAT(torch.nn.Module):
          def __init__(self, in_channels, out_channels):
              super().__init__()
  
              self.convs = torch.nn.ModuleList()
              self.convs.append(GATConv(in_channels, 16, heads=2))
              self.convs.append(GATConv(32, 16, heads=2))
              self.convs.append(
                  GATConv(32, out_channels, heads=2, concat=False)
              )
  
          def batch(self, x, adjs):
              for i, (edge_index, _, size) in enumerate(adjs):
                  x_target = x[
                      : size[1]
                  ]  # Target nodes are always placed first.
                  x = self.convs[i]((x, x_target), edge_index)
              return x
  
          def full(self, x, edge_index):
              for conv in self.convs:
                  x = conv(x, edge_index)
              return x
  
      _, n_id, adjs = next(iter(loader))
      out1 = model.batch(data.x[n_id], adjs)
      out2 = model.full(data.x, data.edge_index)[batch]
      assert torch.allclose(out1, out2, atol=1e-7)
  
file_path: pytorch_geometric/test/loader/test_neighbor_sampler.py
imports: import numpy
  import torch
  from torch_geometric.loader import NeighborSampler
  from torch_geometric.nn.conv import GATConv, SAGEConv
  from torch_geometric.testing import onlyOnline, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import erdos_renyi_graph
label_desc: Use image node_id 3 for calling a global function with example usage: test_neighbor_sampler_on_cora(get_dataset) and returns: x, x, x, x