code: def compute_max_rank(graph):
      #  highly inefficient way to calculate the rank of every node
      ret = {}
      # begin at max rank
      for v in graph.keys():
          if len(graph[v].inputs) == 0:
              ret[v] = 0
          else:
              ret[v] = len(graph)
  
      changes = True
      while changes:
          changes = False
          for v in graph.keys():
              if len(graph[v].inputs) > 0:
                  rank = max(ret[i] for i in graph[v].inputs) + 1
                  if ret[v] != rank:
                      changes = True
                      ret[v] = rank
      return ret
  
file_path: coremltools/coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/cond_to_where.py
imports: from coremltools import _logger
  from coremltools._deps import _HAS_TF_2
  from ..basic_graph_ops import delete_node, disconnect_edge
  from .visitors import FindAllUpstreamTerminals
label_desc: Use image node_id 1 for calling a global function with example usage: compute_max_rank(graph) and returns: ret