class_docstr: A sampling graph in CSC format.
class_docstr_tok: ["A","sampling","graph","in","CSC","format","."]
docstr: An internal function used to convert a fused homogeneous sampled
  subgraph to general struct 'SampledSubgraphImpl'.
docstr_tok: ["An","internal","function","used","to","convert","a","fused","homogeneous","sampled","subgraph","to","general","struct","'SampledSubgraphImpl","'","."]
code: def _convert_to_sampled_subgraph(
      self,
      C_sampled_subgraph: torch.ScriptObject,
  ) -> SampledSubgraphImpl:
      """An internal function used to convert a fused homogeneous sampled
      subgraph to general struct 'SampledSubgraphImpl'."""
      indptr = C_sampled_subgraph.indptr
      indices = C_sampled_subgraph.indices
      type_per_edge = C_sampled_subgraph.type_per_edge
      column = C_sampled_subgraph.original_column_node_ids
      original_edge_ids = C_sampled_subgraph.original_edge_ids
  
      has_original_eids = (
          self.edge_attributes is not None
          and ORIGINAL_EDGE_ID in self.edge_attributes
      )
      if has_original_eids:
          original_edge_ids = torch.ops.graphbolt.index_select(
              self.edge_attributes[ORIGINAL_EDGE_ID], original_edge_ids
          )
      if type_per_edge is None:
          # The sampled graph is already a homogeneous graph.
          sampled_csc = CSCFormatBase(indptr=indptr, indices=indices)
      else:
          # UVA sampling requires us to move node_type_offset to GPU.
          self.node_type_offset = self.node_type_offset.to(
              column.device
          )
          # 1. Find node types for each nodes in column.
          node_types = (
              torch.searchsorted(
                  self.node_type_offset, column, right=True
              )
              - 1
          )
  
          original_hetero_edge_ids = {}
          sub_indices = {}
          sub_indptr = {}
          offset = self._node_type_offset_list
          # 2. For loop each node type.
          for ntype, ntype_id in self.node_type_to_id.items():
              # Get all nodes of a specific node type in column.
              nids = torch.nonzero(node_types == ntype_id).view(-1)
              nids_original_indptr = indptr[nids + 1]
              for etype, etype_id in self.edge_type_to_id.items():
                  src_ntype, _, dst_ntype = etype_str_to_tuple(etype)
                  if dst_ntype != ntype:
                      continue
                  # Get all edge ids of a specific edge type.
                  eids = torch.nonzero(type_per_edge == etype_id).view(
                      -1
                  )
                  src_ntype_id = self.node_type_to_id[src_ntype]
                  sub_indices[etype] = (
                      indices[eids] - offset[src_ntype_id]
                  )
                  cum_edges = torch.searchsorted(
                      eids, nids_original_indptr, right=False
                  )
                  sub_indptr[etype] = torch.cat(
                      (
                          torch.tensor([0], device=indptr.device),
                          cum_edges,
                      )
                  )
                  if has_original_eids:
                      original_hetero_edge_ids[
                          etype
                      ] = original_edge_ids[eids]
          if has_original_eids:
              original_edge_ids = original_hetero_edge_ids
          sampled_csc = {
              etype: CSCFormatBase(
                  indptr=sub_indptr[etype],
                  indices=sub_indices[etype],
              )
              for etype in self.edge_type_to_id.keys()
          }
      return SampledSubgraphImpl(
          sampled_csc=sampled_csc,
          original_edge_ids=original_edge_ids,
      )
  
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 26 for calling the FusedCSCSamplingGraph obj's underlying member method code with example usage: obj._convert_to_sampled_subgraph(C_sampled_subgraph) and returns: SampledSubgraphImpl