code: def test_homo_link_neighbor_loader_triplet(
      disjoint, temporal, amount
  ):
      if not disjoint and temporal:
          return
  
      data = Data()
      data.x = torch.arange(100)
      data.edge_index = get_random_edge_index(100, 100, 400)
      data.edge_label_index = get_random_edge_index(100, 100, 500)
      data.edge_attr = torch.arange(data.num_edges)
  
      time_attr = edge_label_time = None
      if temporal:
          time_attr = "time"
          data.time = torch.arange(data.num_nodes)
  
          edge_label_time = torch.max(
              data.time[data.edge_label_index[0]],
              data.time[data.edge_label_index[1]],
          )
          edge_label_time = edge_label_time + 50
  
      batch_size = 20
      loader = LinkNeighborLoader(
          data,
          num_neighbors=[-1] * 2,
          batch_size=batch_size,
          edge_label_index=data.edge_label_index,
          edge_label_time=edge_label_time,
          time_attr=time_attr,
          disjoint=disjoint,
          neg_sampling=dict(mode="triplet", amount=amount),
          shuffle=True,
      )
  
      assert str(loader) == "LinkNeighborLoader()"
      assert len(loader) == 500 / batch_size
  
      for batch in loader:
          assert isinstance(batch, Data)
  
          # Check that `src_index` and `dst_pos_index` point to valid edges:
          assert torch.equal(
              batch.x[batch.src_index],
              data.edge_label_index[0, batch.input_id],
          )
          assert torch.equal(
              batch.x[batch.dst_pos_index],
              data.edge_label_index[1, batch.input_id],
          )
  
          # Check that `dst_neg_index` points to valid nodes in the batch:
          if amount == 1:
              assert batch.dst_neg_index.size() == (batch_size,)
          else:
              assert batch.dst_neg_index.size() == (batch_size, amount)
          assert batch.dst_neg_index.min() >= 0
          assert batch.dst_neg_index.max() < batch.num_nodes
  
          if disjoint:
              # In disjoint mode, seed nodes should always be placed first:
              assert batch.src_index.min() == 0
              assert batch.src_index.max() == batch_size - 1
  
              assert batch.dst_pos_index.min() == batch_size
              assert batch.dst_pos_index.max() == 2 * batch_size - 1
  
              assert batch.dst_neg_index.min() == 2 * batch_size
              max_seed_nodes = 2 * batch_size + batch_size * amount
              assert batch.dst_neg_index.max() == max_seed_nodes - 1
  
              assert batch.batch.min() == 0
              assert batch.batch.max() == batch_size - 1
  
              # Check that `batch` is always increasing:
              for i in range(0, max_seed_nodes, batch_size):
                  batch_vector = batch.batch[i : i + batch_size]
                  assert torch.equal(
                      batch_vector, torch.arange(batch_size)
                  )
  
          if temporal:
              for i in range(batch_size):
                  assert (
                      batch.time[batch.batch == i].max()
                      <= batch.seed_time[i]
                  )
  
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 11 for calling a global function with example usage: test_homo_link_neighbor_loader_triplet(disjoint, temporal, amount) without return types