code: def _get_ordered_func_heap():
      heap = []
      visited_funcs = set()
  
      def push_heap(func):
          if func not in visited_funcs:
              # Negate since heapq is min-heap
              # The second element is used to make each item unique
              ordered_func = -func.rank, len(visited_funcs), func
              visited_funcs.add(func)
              heapq.heappush(heap, ordered_func)
  
      def pop_heap():
          _, _, func = heapq.heappop(heap)
          return func
  
      return heap, push_heap, pop_heap
  
imports: import collections
  import contextlib
  import heapq
  import inspect
  import traceback
  import weakref
  import six
  import chainer
  from chainer import _backprop_utils
  from chainer import backend
  from chainer.backends import cuda
  from chainer import configuration
  from chainer import function_hook
  from chainer.graph_optimizations.static_graph_utilities import static_forward_optimizations
  from chainer import utils
  from chainer.utils import type_check
  from chainer import variable
  import chainerx
label_desc: Use image node_id 5 for calling a global function with example usage: _get_ordered_func_heap() and returns: heap,  push_heap,  pop_heap, func