docstr: Sample based on node freq in traces, frequently shown
  nodes will have larger chance to be sampled as
  negative node.
docstr_tok: ["Sample","based","on","node","freq","in","traces",",","frequently","shown","nodes","will","have","larger","chance","to","be","sampled","as","negative","node","."]
code: def generate_neg_pairs(self, pos_pairs):
      """
      Sample based on node freq in traces, frequently shown
      nodes will have larger chance to be sampled as
      negative node.
      """
      # sample `self.num_negative` neg dst node
      # for each pos node pair's src node.
      negs = th.multinomial(
          self.node_weights,
          len(pos_pairs) * self.num_negative,
          replacement=True,
      ).tolist()
  
      tar = np.repeat(
          [pair[0] for pair in pos_pairs], self.num_negative
      )
      assert len(tar) == len(negs)
      neg_pairs = [[x, y, 0] for x, y in zip(tar, negs)]
  
      return neg_pairs
  
file_path: dgl/examples/pytorch/eges/sampler.py
imports: import dgl
  import numpy
  import torch
label_desc: Use image node_id 6 for calling the Sampler obj's underlying member method code with example usage: obj.generate_neg_pairs(pos_pairs) and returns: neg_pairs