class_docstr: A sampling graph in CSC format.
class_docstr_tok: ["A","sampling","graph","in","CSC","format","."]
docstr: Sample neighboring edges of the given nodes and return the induced
  subgraph.
  
  Parameters
  ----------
  nodes: torch.Tensor or Dict[str, torch.Tensor]
      IDs of the given seed nodes.
        - If `nodes` is a tensor: It means the graph is homogeneous
          graph, and ids inside are homogeneous ids.
        - If `nodes` is a dictionary: The keys should be node type and
          ids inside are heterogeneous ids.
  fanouts: torch.Tensor
      The number of edges to be sampled for each node with or without
      considering edge types.
        - When the length is 1, it indicates that the fanout applies to
          all neighbors of the node as a collective, regardless of the
          edge type.
        - Otherwise, the length should equal to the number of edge
          types, and each fanout value corresponds to a specific edge
          type of the nodes.
      The value of each fanout should be >= 0 or = -1.
        - When the value is -1, all neighbors (with non-zero probability,
          if weighted) will be sampled once regardless of replacement. It
          is equivalent to selecting all neighbors with non-zero
          probability when the fanout is >= the number of neighbors (and
          replace is set to false).
        - When the value is a non-negative integer, it serves as a
          minimum threshold for selecting neighbors.
  replace: bool
      Boolean indicating whether the sample is preformed with or
      without replacement. If True, a value can be selected multiple
      times. Otherwise, each value can be selected only once.
  probs_name: str, optional
      An optional string specifying the name of an edge attribute used.
      This attribute tensor should contain (unnormalized) probabilities
      corresponding to each neighboring edge of a node. It must be a 1D
      floating-point or boolean tensor, with the number of elements
      equalling the total number of edges.
  
  Returns
  -------
  SampledSubgraphImpl
      The sampled subgraph.
  
  Examples
  --------
  >>> import dgl.graphbolt as gb
  >>> import torch
  >>> ntypes = {"n1": 0, "n2": 1}
  >>> etypes = {"n1:e1:n2": 0, "n2:e2:n1": 1}
  >>> indptr = torch.LongTensor([0, 2, 4, 6, 7, 9])
  >>> indices = torch.LongTensor([2, 4, 2, 3, 0, 1, 1, 0, 1])
  >>> node_type_offset = torch.LongTensor([0, 2, 5])
  >>> type_per_edge = torch.LongTensor([1, 1, 1, 1, 0, 0, 0, 0, 0])
  >>> graph = gb.fused_csc_sampling_graph(indptr, indices,
  ...     node_type_offset=node_type_offset,
  ...     type_per_edge=type_per_edge,
  ...     node_type_to_id=ntypes,
  ...     edge_type_to_id=etypes)
  >>> nodes = {'n1': torch.LongTensor([0]), 'n2': torch.LongTensor([0])}
  >>> fanouts = torch.tensor([1, 1])
  >>> subgraph = graph.sample_neighbors(nodes, fanouts)
  >>> print(subgraph.sampled_csc)
  {'n1:e1:n2': CSCFormatBase(indptr=tensor([0, 1]),
              indices=tensor([0]),
  ), 'n2:e2:n1': CSCFormatBase(indptr=tensor([0, 1]),
              indices=tensor([2]),
  )}
docstr_tok: ["Sample","neighboring","edges","of","the","given","nodes","and","return","the","induced","subgraph",".","Parameters","--","--","--","--","--","nodes",":","torch.Tensor","or","Dict","[","str",",","torch.Tensor","]","IDs","of","the","given","seed","nodes",".","-","If","`","nodes","`","is","a","tensor",":","It","means","the","graph","is","homogeneous","graph",",","and","ids","inside","are","homogeneous","ids",".","-","If","`","nodes","`","is","a","dictionary",":","The","keys","should","be","node","type","and","ids","inside","are","heterogeneous","ids",".","fanouts",":","torch.Tensor","The","number","of","edges","to","be","sampled","for","each","node","with","or","without","considering","edge","types",".","-","When","the","length","is","1",",","it","indicates","that","the","fanout","applies","to","all","neighbors","of","the","node","as","a","collective",",","regardless","of","the","edge","type",".","-","Otherwise",",","the","length","should","equal","to","the","number","of","edge","types",",","and","each","fanout","value","corresponds","to","a","specific","edge","type","of","the","nodes",".","The","value","of","each","fanout","should","be",">","=","0","or","=","-1",".","-","When","the","value","is","-1",",","all","neighbors","(","with","non-zero","probability",",","if","weighted",")","will","be","sampled","once","regardless","of","replacement",".","It","is","equivalent","to","selecting","all","neighbors","with","non-zero","probability","when","the","fanout","is",">","=","the","number","of","neighbors","(","and","replace","is","set","to","false",")",".","-","When","the","value","is","a","non-negative","integer",",","it","serves","as","a","minimum","threshold","for","selecting","neighbors",".","replace",":","bool","Boolean","indicating","whether","the","sample","is","preformed","with","or","without","replacement",".","If","True",",","a","value","can","be","selected","multiple","times",".","Otherwise",",","each","value","can","be","selected","only","once",".","probs_name",":","str",",","optional","An","optional","string","specifying","the","name","of","an","edge","attribute","used",".","This","attribute","tensor","should","contain","(","unnormalized",")","probabilities","corresponding","to","each","neighboring","edge","of","a","node",".","It","must","be","a","1D","floating-point","or","boolean","tensor",",","with","the","number","of","elements","equalling","the","total","number","of","edges",".","Returns","--","--","--","-","SampledSubgraphImpl","The","sampled","subgraph",".","Examples","--","--","--","--",">",">",">","import","dgl.graphbolt","as","gb",">",">",">","import","torch",">",">",">","ntypes","=","{","``","n1","''",":","0",",","``","n2","''",":","1","}",">",">",">","etypes","=","{","``","n1",":","e1",":","n2","''",":","0",",","``","n2",":","e2",":","n1","''",":","1","}",">",">",">","indptr","=","torch.LongTensor","(","[","0",",","2",",","4",",","6",",","7",",","9","]",")",">",">",">","indices","=","torch.LongTensor","(","[","2",",","4",",","2",",","3",",","0",",","1",",","1",",","0",",","1","]",")",">",">",">","node_type_offset","=","torch.LongTensor","(","[","0",",","2",",","5","]",")",">",">",">","type_per_edge","=","torch.LongTensor","(","[","1",",","1",",","1",",","1",",","0",",","0",",","0",",","0",",","0","]",")",">",">",">","graph","=","gb.fused_csc_sampling_graph","(","indptr",",","indices",",","...","node_type_offset=node_type_offset",",","...","type_per_edge=type_per_edge",",","...","node_type_to_id=ntypes",",","...","edge_type_to_id=etypes",")",">",">",">","nodes","=","{","'n1","'",":","torch.LongTensor","(","[","0","]",")",",","'n2","'",":","torch.LongTensor","(","[","0","]",")","}",">",">",">","fanouts","=","torch.tensor","(","[","1",",","1","]",")",">",">",">","subgraph","=","graph.sample_neighbors","(","nodes",",","fanouts",")",">",">",">","print","(","subgraph.sampled_csc",")","{","'n1",":","e1",":","n2","'",":","CSCFormatBase","(","indptr=tensor","(","[","0",",","1","]",")",",","indices=tensor","(","[","0","]",")",",",")",",","'n2",":","e2",":","n1","'",":","CSCFormatBase","(","indptr=tensor","(","[","0",",","1","]",")",",","indices=tensor","(","[","2","]",")",",",")","}"]
code: def sample_neighbors(
      self,
      nodes: Union[torch.Tensor, Dict[str, torch.Tensor]],
      fanouts: torch.Tensor,
      replace: bool = False,
      probs_name: Optional[str] = None,
  ) -> SampledSubgraphImpl:
      """Sample neighboring edges of the given nodes and return the induced
      subgraph.
  
      Parameters
      ----------
      nodes: torch.Tensor or Dict[str, torch.Tensor]
          IDs of the given seed nodes.
            - If `nodes` is a tensor: It means the graph is homogeneous
              graph, and ids inside are homogeneous ids.
            - If `nodes` is a dictionary: The keys should be node type and
              ids inside are heterogeneous ids.
      fanouts: torch.Tensor
          The number of edges to be sampled for each node with or without
          considering edge types.
            - When the length is 1, it indicates that the fanout applies to
              all neighbors of the node as a collective, regardless of the
              edge type.
            - Otherwise, the length should equal to the number of edge
              types, and each fanout value corresponds to a specific edge
              type of the nodes.
          The value of each fanout should be >= 0 or = -1.
            - When the value is -1, all neighbors (with non-zero probability,
              if weighted) will be sampled once regardless of replacement. It
              is equivalent to selecting all neighbors with non-zero
              probability when the fanout is >= the number of neighbors (and
              replace is set to false).
            - When the value is a non-negative integer, it serves as a
              minimum threshold for selecting neighbors.
      replace: bool
          Boolean indicating whether the sample is preformed with or
          without replacement. If True, a value can be selected multiple
          times. Otherwise, each value can be selected only once.
      probs_name: str, optional
          An optional string specifying the name of an edge attribute used.
          This attribute tensor should contain (unnormalized) probabilities
          corresponding to each neighboring edge of a node. It must be a 1D
          floating-point or boolean tensor, with the number of elements
          equalling the total number of edges.
  
      Returns
      -------
      SampledSubgraphImpl
          The sampled subgraph.
  
      Examples
      --------
      >>> import dgl.graphbolt as gb
      >>> import torch
      >>> ntypes = {"n1": 0, "n2": 1}
      >>> etypes = {"n1:e1:n2": 0, "n2:e2:n1": 1}
      >>> indptr = torch.LongTensor([0, 2, 4, 6, 7, 9])
      >>> indices = torch.LongTensor([2, 4, 2, 3, 0, 1, 1, 0, 1])
      >>> node_type_offset = torch.LongTensor([0, 2, 5])
      >>> type_per_edge = torch.LongTensor([1, 1, 1, 1, 0, 0, 0, 0, 0])
      >>> graph = gb.fused_csc_sampling_graph(indptr, indices,
      ...     node_type_offset=node_type_offset,
      ...     type_per_edge=type_per_edge,
      ...     node_type_to_id=ntypes,
      ...     edge_type_to_id=etypes)
      >>> nodes = {'n1': torch.LongTensor([0]), 'n2': torch.LongTensor([0])}
      >>> fanouts = torch.tensor([1, 1])
      >>> subgraph = graph.sample_neighbors(nodes, fanouts)
      >>> print(subgraph.sampled_csc)
      {'n1:e1:n2': CSCFormatBase(indptr=tensor([0, 1]),
                  indices=tensor([0]),
      ), 'n2:e2:n1': CSCFormatBase(indptr=tensor([0, 1]),
                  indices=tensor([2]),
      )}
      """
      if isinstance(nodes, dict):
          nodes = self._convert_to_homogeneous_nodes(nodes)
  
      C_sampled_subgraph = self._sample_neighbors(
          nodes, fanouts, replace, probs_name
      )
      return self._convert_to_sampled_subgraph(C_sampled_subgraph)
  
imports: from typing import Dict, Optional, Union
  import torch
  from dgl.utils import recursive_apply
  from ...base import EID, ETYPE, NID, NTYPE
  from ...convert import to_homogeneous
  from ...heterograph import DGLGraph
  from ..base import etype_str_to_tuple, etype_tuple_to_str, ORIGINAL_EDGE_ID
  from ..sampling_graph import SamplingGraph
  from .sampled_subgraph_impl import CSCFormatBase, SampledSubgraphImpl
label_desc: Use image node_id 27 for calling the FusedCSCSamplingGraph obj's underlying member method code with example usage: obj.sample_neighbors(nodes, fanouts, replace, probs_name) and returns: self