code: def is_isomorphic(graph1, graph2):
      """Exhaustively checks if 2 graphs are isomorphic."""
      matrix1, label1 = np.array(graph1[0]), graph1[1]
      matrix2, label2 = np.array(graph2[0]), graph2[1]
      assert np.shape(matrix1) == np.shape(matrix2)
      assert len(label1) == len(label2)
  
      vertices = np.shape(matrix1)[0]
      # Note: input and output in our constrained graphs always map to themselves
      # but this script does not enforce that.
      for perm in itertools.permutations(range(0, vertices)):
          pmatrix1, plabel1 = permute_graph(matrix1, label1, perm)
          if np.array_equal(pmatrix1, matrix2) and plabel1 == label2:
              return True
  
      return False
  
file_path: singa/examples/model_selection/TRAILS-Database-Native-Model-Selection/internal/ml/model_selection/src/third_pkg/sp101_lib/graph_util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import hashlib
  import itertools
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: is_isomorphic(graph1, graph2) and returns: False, True