code: def test_hgt_loader_on_cora(get_dataset):
      dataset = get_dataset(name="Cora")
      data = dataset[0]
      data.edge_weight = torch.rand(data.num_edges)
  
      hetero_data = HeteroData()
      hetero_data["paper"].x = data.x
      hetero_data["paper"].n_id = torch.arange(data.num_nodes)
      hetero_data["paper", "paper"].edge_index = data.edge_index
      hetero_data["paper", "paper"].edge_weight = data.edge_weight
  
      split_idx = torch.arange(5, 8)
  
      # Sample the complete two-hop neighborhood:
      loader = HGTLoader(
          hetero_data,
          num_samples=[data.num_nodes] * 2,
          batch_size=split_idx.numel(),
          input_nodes=("paper", split_idx),
      )
      assert len(loader) == 1
  
      hetero_batch = next(iter(loader))
      batch_size = hetero_batch["paper"].batch_size
  
      n_id, _, _, e_mask = k_hop_subgraph(
          split_idx,
          num_hops=2,
          edge_index=data.edge_index,
          num_nodes=data.num_nodes,
      )
  
      n_id = n_id.sort()[0]
      assert (
          n_id.tolist() == hetero_batch["paper"].n_id.sort()[0].tolist()
      )
      assert hetero_batch["paper", "paper"].num_edges == int(
          e_mask.sum()
      )
  
      class GNN(torch.nn.Module):
          def __init__(
              self, in_channels, hidden_channels, out_channels
          ):
              super().__init__()
              self.conv1 = GraphConv(in_channels, hidden_channels)
              self.conv2 = GraphConv(hidden_channels, out_channels)
  
          def forward(self, x, edge_index, edge_weight):
              x = self.conv1(x, edge_index, edge_weight).relu()
              x = self.conv2(x, edge_index, edge_weight).relu()
              return x
  
      model = GNN(dataset.num_features, 16, dataset.num_classes)
      hetero_model = to_hetero(model, hetero_data.metadata())
  
      out1 = model(data.x, data.edge_index, data.edge_weight)[split_idx]
      out2 = hetero_model(
          hetero_batch.x_dict,
          hetero_batch.edge_index_dict,
          hetero_batch.edge_weight_dict,
      )["paper"][:batch_size]
      assert torch.allclose(out1, out2, atol=1e-6)
  
file_path: pytorch_geometric/test/loader/test_hgt_loader.py
imports: import numpy
  import torch
  from torch_geometric.data import HeteroData
  from torch_geometric.loader import HGTLoader
  from torch_geometric.nn import GraphConv, to_hetero
  from torch_geometric.testing import get_random_edge_index, onlyOnline, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import k_hop_subgraph
label_desc: Use image node_id 3 for calling a global function with example usage: test_hgt_loader_on_cora(get_dataset) and returns: x