code: def validate_cost_functions(
      G1,
      G2,
      node_substitution_cost=None,
      edge_substitution_cost=None,
      G1_node_deletion_cost=None,
      G1_edge_deletion_cost=None,
      G2_node_insertion_cost=None,
      G2_edge_insertion_cost=None,
  ):
      """Validates cost functions (substitution, insertion, deletion) and initializes them with default=0 for substitution
      and default=1 for insertion/deletion
      if the provided ones are None.
  
  
      Parameters : see graph_edit_distance
  
      """
      num_G1_nodes = G1.num_nodes()
      num_G2_nodes = G2.num_nodes()
  
      num_G1_edges = G1.num_edges()
      num_G2_edges = G2.num_edges()
  
      # if any cost matrix is None, initialize it with default costs
      if node_substitution_cost is None:
          node_substitution_cost = np.zeros(
              (num_G1_nodes, num_G2_nodes), dtype=float
          )
      else:
          assert node_substitution_cost.shape == (
              num_G1_nodes,
              num_G2_nodes,
          )
  
      if edge_substitution_cost is None:
          edge_substitution_cost = np.zeros(
              (num_G1_edges, num_G2_edges), dtype=float
          )
      else:
          assert edge_substitution_cost.shape == (
              num_G1_edges,
              num_G2_edges,
          )
  
      if G1_node_deletion_cost is None:
          G1_node_deletion_cost = np.ones(num_G1_nodes, dtype=float)
      else:
          assert G1_node_deletion_cost.shape[0] == num_G1_nodes
  
      if G1_edge_deletion_cost is None:
          G1_edge_deletion_cost = np.ones(num_G1_edges, dtype=float)
      else:
          assert G1_edge_deletion_cost.shape[0] == num_G1_edges
  
      if G2_node_insertion_cost is None:
          G2_node_insertion_cost = np.ones(num_G2_nodes, dtype=float)
      else:
          assert G2_node_insertion_cost.shape[0] == num_G2_nodes
  
      if G2_edge_insertion_cost is None:
          G2_edge_insertion_cost = np.ones(num_G2_edges, dtype=float)
      else:
          assert G2_edge_insertion_cost.shape[0] == num_G2_edges
  
      return (
          node_substitution_cost,
          edge_substitution_cost,
          G1_node_deletion_cost,
          G1_edge_deletion_cost,
          G2_node_insertion_cost,
          G2_edge_insertion_cost,
      )
  
file_path: dgl/examples/pytorch/graph_matching/ged.py
imports: from copy import deepcopy
  from heapq import heapify, heappop, heappush, nsmallest
  import dgl
  import numpy
  from lapjv import lapjv
label_desc: Use image node_id 1 for calling a global function with example usage: validate_cost_functions(G1, G2, node_substitution_cost, edge_substitution_cost, G1_node_deletion_cost, G1_edge_deletion_cost, G2_node_insertion_cost, G2_edge_insertion_cost) and returns: node_substitution_cost,  edge_substitution_cost,  G1_node_deletion_cost,  G1_edge_deletion_cost,  G2_node_insertion_cost,  G2_edge_insertion_cost