class_docstr: class object to do uniform sampling
class_docstr_tok: ["class","object","to","do","uniform","sampling"]
docstr: Sample neighboring edges of the given nodes and return the subgraph.
  
  Parameters
  ----------
  nodes_ar : cupy array of node ids or dict with key of node type
             and value of node ids gto sample neighbors from.
  fanout : int
      The number of edges to be sampled for each node on each edge type.
      If -1 is given all the neighboring edges for each node on
      each edge type will be selected.
  edge_dir : str {"in" or "out"}
      Determines whether to sample inbound or outbound edges.
      Can take either in for inbound edges or out for outbound edges.
  prob : str
      Feature name used as the (unnormalized) probabilities associated
      with each neighboring edge of a node. Each feature must be a
      scalar. The features must be non-negative floats, and the sum of
      the features of inbound/outbound edges for every node must be
      positive (though they don't have to sum up to one). Otherwise,
      the result will be undefined. If not specified, sample uniformly.
  replace : bool
      If True, sample with replacement.
  Returns
  -------
  [src, dst, eids] or {etype1:[src, dst, eids],...,}
docstr_tok: ["Sample","neighboring","edges","of","the","given","nodes","and","return","the","subgraph",".","Parameters","--","--","--","--","--","nodes_ar",":","cupy","array","of","node","ids","or","dict","with","key","of","node","type","and","value","of","node","ids","gto","sample","neighbors","from",".","fanout",":","int","The","number","of","edges","to","be","sampled","for","each","node","on","each","edge","type",".","If","-1","is","given","all","the","neighboring","edges","for","each","node","on","each","edge","type","will","be","selected",".","edge_dir",":","str","{","``","in","''","or","``","out","''","}","Determines","whether","to","sample","inbound","or","outbound","edges",".","Can","take","either","in","for","inbound","edges","or","out","for","outbound","edges",".","prob",":","str","Feature","name","used","as","the","(","unnormalized",")","probabilities","associated","with","each","neighboring","edge","of","a","node",".","Each","feature","must","be","a","scalar",".","The","features","must","be","non-negative","floats",",","and","the","sum","of","the","features","of","inbound\/outbound","edges","for","every","node","must","be","positive","(","though","they","do","n't","have","to","sum","up","to","one",")",".","Otherwise",",","the","result","will","be","undefined",".","If","not","specified",",","sample","uniformly",".","replace",":","bool","If","True",",","sample","with","replacement",".","Returns","--","--","--","-","[","src",",","dst",",","eids","]","or","{","etype1",":","[","src",",","dst",",","eids","]",",","...",",","}"]
code: def sample_neighbors(
      self, nodes_ar, fanout=-1, edge_dir="in", prob=None, replace=False
  ):
      """
      Sample neighboring edges of the given nodes and return the subgraph.
  
      Parameters
      ----------
      nodes_ar : cupy array of node ids or dict with key of node type
                 and value of node ids gto sample neighbors from.
      fanout : int
          The number of edges to be sampled for each node on each edge type.
          If -1 is given all the neighboring edges for each node on
          each edge type will be selected.
      edge_dir : str {"in" or "out"}
          Determines whether to sample inbound or outbound edges.
          Can take either in for inbound edges or out for outbound edges.
      prob : str
          Feature name used as the (unnormalized) probabilities associated
          with each neighboring edge of a node. Each feature must be a
          scalar. The features must be non-negative floats, and the sum of
          the features of inbound/outbound edges for every node must be
          positive (though they don't have to sum up to one). Otherwise,
          the result will be undefined. If not specified, sample uniformly.
      replace : bool
          If True, sample with replacement.
      Returns
      -------
      [src, dst, eids] or {etype1:[src, dst, eids],...,}
      """
  
      if prob is not None:
          raise NotImplementedError(
              "prob is not currently supported",
              " for sample_neighbors in CuGraphStorage",
          )
  
      if edge_dir not in ["in", "out"]:
          raise ValueError(
              f"edge_dir must be either 'in' or 'out' got {edge_dir} instead"
          )
  
      if self.has_multiple_etypes:
          # TODO: Convert into a single call when
          # https://github.com/rapidsai/cugraph/issues/2696 lands
          if edge_dir == "in":
              (
                  sgs_obj,
                  sgs_src_range_obj,
              ) = self.extracted_reverse_subgraphs_per_type
          else:
              (
                  sgs_obj,
                  sgs_src_range_obj,
              ) = self.extracted_subgraphs_per_type
          first_sg = list(sgs_obj.values())[0]
      else:
          if edge_dir == "in":
              (
                  sgs_obj,
                  sgs_src_range_obj,
              ) = self.extracted_reverse_subgraph
          else:
              sgs_obj, sgs_src_range_obj = self.extracted_subgraph
  
          first_sg = sgs_obj
      # Uniform sampling fails when the dtype
      # of the seed dtype is not same as the node dtype
      self.set_sg_node_dtype(first_sg)
  
      if self.single_gpu:
          sample_f = cugraph.uniform_neighbor_sample
      else:
          sample_f = cugraph.dask.uniform_neighbor_sample
  
      sampled_df = sample_cugraph_graphs(
          sample_f=sample_f,
          has_multiple_etypes=self.has_multiple_etypes,
          sgs_obj=sgs_obj,
          sgs_src_range_obj=sgs_src_range_obj,
          sg_node_dtype=self._sg_node_dtype,
          nodes_ar=nodes_ar,
          replace=replace,
          fanout=fanout,
          edge_dir=edge_dir,
      )
  
      if self.has_multiple_etypes:
          # Heterogeneous graph case
          # Add type information
          return self._get_edgeid_type_d(sampled_df)
      else:
          return (
              sampled_df[src_n].values,
              sampled_df[dst_n].values,
              sampled_df["indices"].values,
          )
  
file_path: cugraph/python/cugraph/cugraph/gnn/dgl_extensions/dgl_uniform_sampler.py
imports: from functools import cached_property
  import cugraph
  import cudf
  import cupy
  from cugraph.gnn.dgl_extensions.utils.sampling import sample_cugraph_graphs, get_subgraph_and_src_range_from_edgelist, get_underlying_dtype_from_sg
  from cugraph.gnn.dgl_extensions.utils.sampling import src_n, dst_n
label_desc: Use image node_id 2 for calling the DGLUniformSampler obj's underlying member method code with example usage: obj.sample_neighbors(nodes_ar, fanout, edge_dir, prob, replace) and returns: self, sampled_df,  sampled_df,  sampled_df