code: def __split_edges_train_test(
      cls, g: dgl.DGLGraph, train_ratio: float
  ) -> _typing.Tuple[
      dgl.DGLGraph,
      dgl.DGLGraph,
      dgl.DGLGraph,
      dgl.DGLGraph,
      dgl.DGLGraph,
  ]:
      u, v = g.edges()
  
      eids = np.arange(g.number_of_edges())
      eids = np.random.permutation(eids)
      test_size = int(len(eids) * (1 - train_ratio))
      train_size = g.number_of_edges() - test_size
      test_pos_u, test_pos_v = u[eids[:test_size]], v[eids[:test_size]]
      train_pos_u, train_pos_v = (
          u[eids[test_size:]],
          v[eids[test_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]],
      )
      train_neg_u, train_neg_v = (
          neg_u[neg_eids[test_size:]],
          neg_v[neg_eids[test_size:]],
      )
  
      train_g = dgl.remove_edges(g, eids[:test_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()
      )
  
      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, test_pos_g, test_neg_g
  
file_path: AutoGL/autogl/datasets/utils/_split_edges/_dgl_compatible.py
imports: import numpy
  import scipy.sparse
  import typing
  import dgl
  import autogl.data.graph
  from autogl.data.graph.utils.conversion import general_static_graph_to_dgl_graph
label_desc: Use image node_id 2 for calling the _SplitEdgesDGLImpl obj's underlying member method code with example usage: obj.__split_edges_train_test(cls, g, train_ratio) and returns: train_g,  train_pos_g,  train_neg_g,  test_pos_g,  test_neg_g