code: def subgraph_isomorphism_edge_counts(edge_index, subgraph_dict):
      ##### edge structural identifiers #####
  
      edge_index = edge_index.transpose(1, 0).cpu().numpy()
      edge_dict = {}
      for i, edge in enumerate(edge_index):
          edge_dict[tuple(edge)] = i
  
      subgraph_edges = to_undirected(
          torch.tensor(subgraph_dict["subgraph"].get_edges().tolist())
      )
  
      G_gt = gt.Graph(directed=False)
      G_gt.add_edge_list(list(edge_index))
      gt.stats.remove_self_loops(G_gt)
      gt.stats.remove_parallel_edges(G_gt)
  
      # compute all subgraph isomorphisms
      sub_iso = gt_topology.subgraph_isomorphism(
          subgraph_dict["subgraph"],
          G_gt,
          induced=True,
          subgraph=True,
          generator=True,
      )
  
      counts = np.zeros(
          (edge_index.shape[0], len(subgraph_dict["orbit_partition"]))
      )
  
      for sub_iso_curr in sub_iso:
          mapping = sub_iso_curr.get_array()
          for i, edge in enumerate(subgraph_edges):
              # for every edge in the graph H, find the edge in the subgraph G_S to which it is mapped
              # (by finding where its endpoints are matched).
              # Then, increase the count of the matched edge w.r.t. the corresponding orbit
              # Repeat for the reverse edge (the one with the opposite direction)
  
              edge_orbit = subgraph_dict["orbit_membership"][i]
              mapped_edge = tuple([mapping[edge[0]], mapping[edge[1]]])
              counts[edge_dict[mapped_edge], edge_orbit] += 1
  
      counts = counts / subgraph_dict["aut_count"]
  
      counts = torch.tensor(counts)
  
      return counts
  
file_path: dgl/examples/pytorch/ogb/directional_GSN/preprocessing.py
imports: import os
  import graph_tool
  import graph_tool.topology
  import networkx
  import numpy
  import torch
  from dgl.data.utils import load_graphs, save_graphs
  from ogb.graphproppred import DglGraphPropPredDataset
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: subgraph_isomorphism_edge_counts(edge_index, subgraph_dict) and returns: counts