docstr: g : the whole graph
  seed_nodes : the output nodes for the current layer
  weight : the weight of the edges
  return : the unnormalized probability of the candidate nodes, as well as the subgraph
           containing all the edges from the candidate nodes to the output nodes.
docstr_tok: ["g",":","the","whole","graph","seed_nodes",":","the","output","nodes","for","the","current","layer","weight",":","the","weight","of","the","edges","return",":","the","unnormalized","probability","of","the","candidate","nodes",",","as","well","as","the","subgraph","containing","all","the","edges","from","the","candidate","nodes","to","the","output","nodes","."]
code: def compute_prob(self, g, seed_nodes, weight, num):
      """
      g : the whole graph
      seed_nodes : the output nodes for the current layer
      weight : the weight of the edges
      return : the unnormalized probability of the candidate nodes, as well as the subgraph
               containing all the edges from the candidate nodes to the output nodes.
      """
      insg = dgl.in_subgraph(g, seed_nodes)
      insg = dgl.compact_graphs(insg, seed_nodes)
      if self.importance_sampling:
          out_frontier = dgl.reverse(insg, copy_edata=True)
          weight = weight[out_frontier.edata[dgl.EID].long()]
          prob = dgl.ops.copy_e_sum(out_frontier, weight**2)
          # prob = torch.sqrt(prob)
      else:
          prob = torch.ones(insg.num_nodes())
          prob[insg.out_degrees() == 0] = 0
      return prob, insg
  
file_path: dgl/examples/pytorch/labor/ladies_sampler.py
imports: import dgl
  import dgl.function
  import torch
label_desc: Use image node_id 2 for calling the LadiesSampler obj's underlying member method code with example usage: obj.compute_prob(g, seed_nodes, weight, num) and returns: prob,  insg