code: def all_pairs_shortest_path(graph, cutoff=None, num_workers=4):
      nodes = list(graph.nodes)
      random.shuffle(nodes)
      pool = mp.Pool(processes=num_workers)
      interval_size = len(nodes) / num_workers
      results = [
          pool.apply_async(
              shortest_path,
              args=(
                  graph,
                  nodes[
                      int(interval_size * i) : int(
                          interval_size * (i + 1)
                      )
                  ],
                  cutoff,
              ),
          )
          for i in range(num_workers)
      ]
      output = [p.get() for p in results]
      dists_dict = merge_dicts(output)
      pool.close()
      pool.join()
      return dists_dict
  
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 9 for calling a global function with example usage: all_pairs_shortest_path(graph, cutoff, num_workers) and returns: dists_dict