code: def split_train_valid_test(g):
      u, v = g.edges()
  
      eids = np.arange(g.number_of_edges())
      eids = np.random.permutation(eids)
  
      valid_size = int(len(eids) * 0.1)
      test_size = int(len(eids) * 0.1)
      train_size = g.number_of_edges() - test_size - valid_size
  
      test_pos_u, test_pos_v = u[eids[:test_size]], v[eids[:test_size]]
      valid_pos_u, valid_pos_v = (
          u[eids[test_size : test_size + valid_size]],
          v[eids[test_size : test_size + valid_size]],
      )
      train_pos_u, train_pos_v = (
          u[eids[test_size + valid_size :]],
          v[eids[test_size + valid_size :]],
      )
  
      # Find all negative edges and split them for training and testing
      adj = sp.coo_matrix((np.ones(len(u)), (u.numpy(), v.numpy())))
      adj_neg = 1 - adj.todense() - np.eye(g.number_of_nodes())
      neg_u, neg_v = np.where(adj_neg != 0)
  
      neg_eids = np.random.choice(len(neg_u), g.number_of_edges())
      test_neg_u, test_neg_v = (
          neg_u[neg_eids[:test_size]],
          neg_v[neg_eids[:test_size]],
      )
      valid_neg_u, valid_neg_v = (
          neg_u[neg_eids[test_size : test_size + valid_size]],
          neg_v[neg_eids[test_size : test_size + valid_size]],
      )
      train_neg_u, train_neg_v = (
          neg_u[neg_eids[test_size + valid_size :]],
          neg_v[neg_eids[test_size + valid_size :]],
      )
  
      train_g = dgl.remove_edges(g, eids[: test_size + valid_size])
  
      train_pos_g = dgl.graph(
          (train_pos_u, train_pos_v), num_nodes=g.number_of_nodes()
      )
      train_neg_g = dgl.graph(
          (train_neg_u, train_neg_v), num_nodes=g.number_of_nodes()
      )
  
      valid_pos_g = dgl.graph(
          (valid_pos_u, valid_pos_v), num_nodes=g.number_of_nodes()
      )
      valid_neg_g = dgl.graph(
          (valid_neg_u, valid_neg_v), num_nodes=g.number_of_nodes()
      )
  
      test_pos_g = dgl.graph(
          (test_pos_u, test_pos_v), num_nodes=g.number_of_nodes()
      )
      test_neg_g = dgl.graph(
          (test_neg_u, test_neg_v), num_nodes=g.number_of_nodes()
      )
  
      return (
          train_g,
          train_pos_g,
          train_neg_g,
          valid_pos_g,
          valid_neg_g,
          test_pos_g,
          test_neg_g,
      )
  
file_path: AutoGL/test/performance/link_prediction/dgl/trainer.py
imports: from tqdm import tqdm
  from autogl.module.train.evaluation import Auc
  import random
  import torch
  import numpy
  import dgl
  import torch
  import numpy
  import scipy.sparse
  from helper import get_encoder_decoder_hp
  from dgl.data import CoraGraphDataset, PubmedGraphDataset, CiteseerGraphDataset
  from autogl.module.train.link_prediction_full import LinkPredictionTrainer
label_desc: Use image node_id 2 for calling a global function with example usage: split_train_valid_test(g) and returns: train_g,  train_pos_g,  train_neg_g,  valid_pos_g,  valid_neg_g,  test_pos_g,  test_neg_g