code: def test_edge_index_to_vector_and_vice_versa():
      # Create a fully-connected graph:
      N = 10
      row = torch.arange(N).view(-1, 1).repeat(1, N).view(-1)
      col = torch.arange(N).view(1, -1).repeat(N, 1).view(-1)
      edge_index = torch.stack([row, col], dim=0)
  
      idx, population = edge_index_to_vector(
          edge_index, (N, N), bipartite=True
      )
      assert population == N * N
      assert idx.tolist() == list(range(population))
      edge_index2 = vector_to_edge_index(idx, (N, N), bipartite=True)
      assert is_undirected(edge_index2)
      assert edge_index.tolist() == edge_index2.tolist()
  
      idx, population = edge_index_to_vector(
          edge_index, (N, N), bipartite=False
      )
      assert population == N * N - N
      assert idx.tolist() == list(range(population))
      mask = edge_index[0] != edge_index[1]  # Remove self-loops.
      edge_index2 = vector_to_edge_index(idx, (N, N), bipartite=False)
      assert is_undirected(edge_index2)
      assert edge_index[:, mask].tolist() == edge_index2.tolist()
  
      idx, population = edge_index_to_vector(
          edge_index, (N, N), bipartite=False, force_undirected=True
      )
      assert population == (N * (N + 1)) / 2 - N
      assert idx.tolist() == list(range(population))
      mask = edge_index[0] != edge_index[1]  # Remove self-loops.
      edge_index2 = vector_to_edge_index(
          idx, (N, N), bipartite=False, force_undirected=True
      )
      assert is_undirected(edge_index2)
      assert (
          edge_index[:, mask].tolist()
          == to_undirected(edge_index2).tolist()
      )
  
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 2 for calling a global function with example usage: test_edge_index_to_vector_and_vice_versa() without return types