code: def get_subgraph(
      out_indices: Tensor,
      graph: Data,
      return_edge_index_type: str,
      adj: SparseTensor,
      **kwargs,
  ):
      if return_edge_index_type == "adj":
          assert adj is not None
  
      if return_edge_index_type == "adj":
          subg = Data(
              x=graph.x[out_indices],
              y=graph.y[out_indices],
              edge_index=adj[out_indices, :][:, out_indices],
          )
      elif return_edge_index_type == "edge_index":
          edge_index, edge_attr = subgraph(
              out_indices,
              graph.edge_index,
              graph.edge_attr,
              relabel_nodes=True,
              num_nodes=graph.num_nodes,
              return_edge_mask=False,
          )
          subg = Data(
              x=graph.x[out_indices],
              y=graph.y[out_indices],
              edge_index=edge_index,
              edge_attr=edge_attr,
          )
      else:
          raise NotImplementedError
  
      for k, v in kwargs.items():
          subg[k] = v
  
      return subg
  
imports: import logging
  import math
  from typing import Callable, Iterator, List, NamedTuple, Optional, Tuple, Union
  import numpy
  import scipy.sparse
  import torch
  from torch import Tensor
  from tqdm import tqdm
  from torch_geometric.data import Data
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import get_ppr, is_undirected, subgraph
label_desc: Use image node_id 4 for calling a global function with example usage: get_subgraph(out_indices, graph, return_edge_index_type, adj) and returns: subg