code: def test_structured_negative_sampling():
      edge_index = torch.as_tensor([[0, 0, 1, 2], [0, 1, 2, 3]])
  
      i, j, k = structured_negative_sampling(edge_index)
      assert i.size(0) == edge_index.size(1)
      assert j.size(0) == edge_index.size(1)
      assert k.size(0) == edge_index.size(1)
  
      adj = torch.zeros(4, 4, dtype=torch.bool)
      adj[i, j] = 1
  
      neg_adj = torch.zeros(4, 4, dtype=torch.bool)
      neg_adj[i, k] = 1
      assert (adj & neg_adj).sum() == 0
  
      # Test with no self-loops:
      edge_index = torch.LongTensor([[0, 0, 1, 1, 2], [1, 2, 0, 2, 1]])
      i, j, k = structured_negative_sampling(
          edge_index, num_nodes=4, contains_neg_self_loops=False
      )
      neg_edge_index = torch.vstack([i, k])
      assert not contains_self_loops(neg_edge_index)
  
file_path: pytorch_geometric/test/utils/test_negative_sampling.py
imports: import torch
  from torch_geometric.utils import batched_negative_sampling, contains_self_loops, is_undirected, negative_sampling, structured_negative_sampling, structured_negative_sampling_feasible, to_undirected
  from torch_geometric.utils._negative_sampling import edge_index_to_vector, vector_to_edge_index
label_desc: Use image node_id 7 for calling a global function with example usage: test_structured_negative_sampling() without return types