docstr: seed_nodes : output nodes
  cand_nodes : candidate nodes.  Must contain all output nodes in @seed_nodes
  prob : unnormalized probability of each candidate node
  num : number of neighbors to sample
  return : the set of input nodes in terms of their indices in @cand_nodes, and also the indices of
           seed nodes in the selected nodes.
docstr_tok: ["seed_nodes",":","output","nodes","cand_nodes",":","candidate","nodes",".","Must","contain","all","output","nodes","in","@","seed_nodes","prob",":","unnormalized","probability","of","each","candidate","node","num",":","number","of","neighbors","to","sample","return",":","the","set","of","input","nodes","in","terms","of","their","indices","in","@","cand_nodes",",","and","also","the","indices","of","seed","nodes","in","the","selected","nodes","."]
code: def select_neighbors(self, prob, num):
      """
      seed_nodes : output nodes
      cand_nodes : candidate nodes.  Must contain all output nodes in @seed_nodes
      prob : unnormalized probability of each candidate node
      num : number of neighbors to sample
      return : the set of input nodes in terms of their indices in @cand_nodes, and also the indices of
               seed nodes in the selected nodes.
      """
      # The returned nodes should be a union of seed_nodes plus @num nodes from cand_nodes.
      # Because compute_prob returns a compacted subgraph and a list of probabilities,
      # we need to find the corresponding local IDs of the resulting union in the subgraph
      # so that we can compute the edge weights of the block.
      # This is why we need a find_indices_in() function.
      neighbor_nodes_idx = torch.multinomial(
          prob, min(num, prob.shape[0]), replacement=self.replace
      )
      return neighbor_nodes_idx
  
file_path: dgl/examples/pytorch/labor/ladies_sampler.py
imports: import dgl
  import dgl.function
  import torch
label_desc: Use image node_id 3 for calling the LadiesSampler obj's underlying member method code with example usage: obj.select_neighbors(prob, num) and returns: neighbor_nodes_idx