code: def _slice_subgraph(subgraph: SampledSubgraph, index: torch.Tensor):
      """Slice the subgraph according to the index."""
  
      def _index_select(obj, index):
          if obj is None:
              return None
          if index is None:
              return obj
          if isinstance(obj, CSCFormatBase):
              new_indices = obj.indices[index]
              new_indptr = torch.searchsorted(index, obj.indptr)
              return CSCFormatBase(
                  indptr=new_indptr,
                  indices=new_indices,
              )
          if isinstance(obj, torch.Tensor):
              return obj[index]
          # Handle the case when obj is a dictionary.
          assert isinstance(obj, dict)
          assert isinstance(index, dict)
          ret = {}
          for k, v in obj.items():
              ret[k] = _index_select(v, index[k])
          return ret
  
      return (
          _index_select(subgraph.sampled_csc, index),
          subgraph.original_column_node_ids,
          subgraph.original_row_node_ids,
          _index_select(subgraph.original_edge_ids, index),
      )
  
file_path: dgl/python/dgl/graphbolt/sampled_subgraph.py
imports: from typing import Dict, Tuple, Union
  import torch
  from dgl.utils import recursive_apply
  from .base import apply_to, CSCFormatBase, etype_str_to_tuple, isin
label_desc: Use image node_id 4 for calling a global function with example usage: _slice_subgraph(subgraph, index) and returns: _index_select,  subgraph,  subgraph,  _index_select, ret, None, obj, CSCFormatBase, obj