code: def _negative_sample_dgl(train_graph, pos_graph):
      import scipy.sparse as sp
      import dgl
  
      u, v = train_graph.edges()
      up, vp = pos_graph.edges()
      u_all, v_all = np.concatenate(
          [u.numpy(), up.numpy()]
      ), np.concatenate([v.numpy(), vp.numpy()])
      adj = sp.coo_matrix((np.ones(len(u_all)), (u_all, v_all)))
      adj_neg = (
          1 - adj.todense() - np.eye(train_graph.number_of_nodes())
      )
      neg_u, neg_v = np.where(adj_neg != 0)
  
      # sample negative edges
      neg_eids = np.random.choice(len(neg_u), len(up))
      return dgl.DGLGraph(
          (neg_u[:neg_eids], neg_v[:neg_eids]),
          num_nodes=train_graph.number_of_nodes(),
      )
  
imports: import logging
  import time
  import json
  from copy import deepcopy
  from typing import Sequence
  import torch
  import numpy
  import yaml
  from .base import BaseClassifier
  from ..base import _parse_hp_space, _initialize_single_model, _parse_model_hp
  from ...module.feature import FEATURE_DICT
  from ...module.train import TRAINER_DICT, BaseLinkPredictionTrainer
  from ...module.train import get_feval
  from ..utils import LeaderBoard, get_graph_node_features, convert_dataset, set_seed
  from ...datasets import utils
  from ..utils import get_logger
  from ...backend import DependentBackend
label_desc: Use image node_id 1 for calling a global function with example usage: _negative_sample_dgl(train_graph, pos_graph) and returns: dgl