code: def test_hetero_link_neighbor_loader_basic(
      subgraph_type, neg_sampling_ratio
  ):
      data = HeteroData()
  
      data["paper"].x = torch.arange(100)
      data["author"].x = torch.arange(100, 300)
  
      data["paper", "paper"].edge_index = get_random_edge_index(
          100, 100, 500
      )
      data["paper", "paper"].edge_attr = torch.arange(500)
      data["paper", "author"].edge_index = get_random_edge_index(
          100, 200, 1000
      )
      data["paper", "author"].edge_attr = torch.arange(500, 1500)
      data["author", "paper"].edge_index = get_random_edge_index(
          200, 100, 1000
      )
      data["author", "paper"].edge_attr = torch.arange(1500, 2500)
  
      loader = LinkNeighborLoader(
          data,
          num_neighbors=[-1] * 2,
          edge_label_index=("paper", "author"),
          batch_size=20,
          subgraph_type=subgraph_type,
          neg_sampling_ratio=neg_sampling_ratio,
          shuffle=True,
      )
  
      assert str(loader) == "LinkNeighborLoader()"
      assert len(loader) == 1000 / 20
  
      for batch in loader:
          assert isinstance(batch, HeteroData)
          if neg_sampling_ratio is None:
              # Assert only positive samples are present in the original graph:
              edge_index = unique_edge_pairs(
                  batch["paper", "author"].edge_index
              )
              edge_label_index = batch[
                  "paper", "author"
              ].edge_label_index
              edge_label_index = unique_edge_pairs(edge_label_index)
              assert len(edge_index | edge_label_index) == len(
                  edge_index
              )
  
          else:
              assert (
                  batch["paper", "author"].edge_label_index.size(1)
                  == 40
              )
              assert torch.all(
                  batch["paper", "author"].edge_label[:20] == 1
              )
              assert torch.all(
                  batch["paper", "author"].edge_label[20:] == 0
              )
  
file_path: pytorch_geometric/test/loader/test_link_neighbor_loader.py
imports: import pytest
  import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.loader import LinkNeighborLoader
  from torch_geometric.testing import MyFeatureStore, MyGraphStore, get_random_edge_index, onlyNeighborSampler, withCUDA, withPackage
label_desc: Use image node_id 3 for calling a global function with example usage: test_hetero_link_neighbor_loader_basic(subgraph_type, neg_sampling_ratio) without return types