code: def precompute_dist_data(edge_index, num_nodes, approximate=0):
      """
      Here dist is 1/real_dist, higher actually means closer, 0 means disconnected
      :return:
      """
      graph = nx.Graph()
      edge_list = edge_index.transpose(1, 0).tolist()
      graph.add_edges_from(edge_list)
  
      n = num_nodes
      dists_array = np.zeros((n, n))
      dists_dict = all_pairs_shortest_path(
          graph, cutoff=approximate if approximate > 0 else None
      )
      node_list = graph.nodes()
      for node_i in node_list:
          shortest_dist = dists_dict[node_i]
          for node_j in node_list:
              dist = shortest_dist.get(node_j, -1)
              if dist != -1:
                  dists_array[node_i, node_j] = 1 / (dist + 1)
      return dists_array
  
imports: import multiprocessing
  import random
  from multiprocessing import get_context
  import networkx
  import numpy
  import torch
  from tqdm.auto import tqdm
label_desc: Use image node_id 10 for calling a global function with example usage: precompute_dist_data(edge_index, num_nodes, approximate) and returns: dists_array