code: def topk_ppr_matrix(
      edge_index: Tensor,
      num_nodes: int,
      alpha: float,
      eps: float,
      output_node_indices: Union[np.ndarray, torch.LongTensor],
      topk: int,
      normalization="row",
  ) -> Tuple[scipy.sparse.csr_matrix, List[np.ndarray]]:
      neighbors, weights = get_ppr(
          edge_index, alpha, eps, output_node_indices, num_nodes
      )
  
      _, neighbor_counts = neighbors[0].unique(return_counts=True)
  
      ppr_matrix = SparseTensor(
          row=torch.arange(len(output_node_indices)).repeat_interleave(
              neighbor_counts
          ),
          col=neighbors[1],
          value=weights,
          sparse_sizes=(len(output_node_indices), num_nodes),
      ).to_scipy(layout="csr")
  
      neighbors = [
          n.cpu().numpy()
          for n in torch.split(
              neighbors[1], neighbor_counts.cpu().tolist(), dim=0
          )
      ]
      weights = [
          n.cpu().numpy()
          for n in torch.split(
              weights, neighbor_counts.cpu().tolist(), dim=0
          )
      ]
  
      def sparsify(
          neighbors: List[np.ndarray],
          weights: List[np.ndarray],
          topk: int,
      ):
          new_neighbors = []
          for n, w in zip(neighbors, weights):
              idx_topk = np.argsort(w)[-topk:]
              new_neighbor = n[idx_topk]
              new_neighbors.append(new_neighbor)
  
          return new_neighbors
  
      neighbors = sparsify(neighbors, weights, topk)
      neighbors = [
          np.union1d(nei, pr)
          for nei, pr in zip(neighbors, output_node_indices)
      ]
  
      _, out_degree = torch.unique(
          edge_index[0], sorted=True, return_counts=True
      )
      if normalization == "sym":
          # Assume undirected (symmetric) adjacency matrix
          deg_sqrt = np.sqrt(np.maximum(out_degree, 1e-12))
          deg_inv_sqrt = 1.0 / deg_sqrt
  
          row, col = ppr_matrix.nonzero()
          ppr_matrix.data = (
              deg_sqrt[output_node_indices[row]]
              * ppr_matrix.data
              * deg_inv_sqrt[col]
          )
      elif normalization == "col":
          # Assume undirected (symmetric) adjacency matrix
          deg_inv = 1.0 / np.maximum(out_degree, 1e-12)
  
          row, col = ppr_matrix.nonzero()
          ppr_matrix.data = (
              out_degree[output_node_indices[row]]
              * ppr_matrix.data
              * deg_inv[col]
          )
      elif normalization == "row":
          pass
      else:
          raise ValueError(
              f"Unknown PPR normalization: {normalization}"
          )
  
      return ppr_matrix, neighbors
  
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 11 for calling a global function with example usage: topk_ppr_matrix(edge_index, num_nodes, alpha, eps, output_node_indices, topk, normalization) and returns: ppr_matrix,  neighbors, new_neighbors