code: def tensor_pagerank(
      edge_index, num_nodes, alpha=0.85, max_iter=100, tol=1.0e-6
  ):
      out_edge = {}
      for i in range(edge_index.shape[1]):
          node = edge_index[0][i].item()
          if node in out_edge:
              out_edge[node].add(edge_index[1][i].item())
          else:
              out_edge[node] = set([edge_index[1][i].item()])
      for node in range(num_nodes):
          if node not in out_edge:
              out_edge[node] = set()
      x = {}
      p = {}
      for node in range(num_nodes):
          x[node] = 1.0 / num_nodes
          p[node] = 1.0 / num_nodes
      dangling_weights = p
      dangling_nodes = [
          n for n in range(num_nodes) if len(out_edge[n]) == 0.0
      ]
      for _ in range(max_iter):
          xlast = x
          x = dict.fromkeys(xlast.keys(), 0)
          danglesum = alpha * sum(xlast[n] for n in dangling_nodes)
          for n in x:
              for nbr in out_edge[n]:
                  x[nbr] += alpha * xlast[n] * (1.0 / len(out_edge[n]))
              x[n] += danglesum * dangling_weights.get(n, 0) + (
                  1.0 - alpha
              ) * p.get(n, 0)
          err = sum([abs(x[n] - xlast[n]) for n in x])
          if err < num_nodes * tol:
              feature = torch.tensor(
                  [x[node] for node in range(num_nodes)],
                  dtype=torch.float32,
              ).view(num_nodes, 1)
              return feature, x
  
file_path: deepsnap/benchmark/transform/pagerank_clustering.py
imports: import time
  import torch
  import argparse
  import deepsnap
  import numpy
  from deepsnap.dataset import GraphDataset
  from torch_geometric.datasets import TUDataset
label_desc: Use image node_id 4 for calling a global function with example usage: tensor_pagerank(edge_index, num_nodes, alpha, max_iter, tol) and returns: feature,  x