code: def _all_assert_leaves(gdict, nodename, memo):
      """
      Does the given node lead to only assertions?
  
      Args:
          gdict (dict): The node's graph.
          nodename (str): The name of the node to test.
          memo (dict): Storage for memoization.
      """
      work = [nodename]
      while True:
          assert len(work) <= len(
              gdict
          )  # If true, this algorithm is broken
          node = gdict[work.pop()]
  
          # Entries in memo have one of the following values for a given node:
          #  None: the node is in the stack; this node is downstream.
          #  True: the node is an assertion or leads only to assertions.
          # False: the node does not lead only to assertions.
          if not isinstance(memo.get(node.name), bool):
              memo[node.name] = None
              outputs = node.outputs
              if len(outputs) == 0:
                  # Leaf node: stack shrinks
                  memo[node.name] = node.op in (
                      "Assert",
                      "CheckNumerics",
                  )
              else:
                  outputs_to_process = [
                      n for n in outputs if n not in memo
                  ]
                  if len(outputs_to_process) == 0:
                      # Non-leaf node with fully processed outputs: stack shrinks
                      memo[node.name] = all(memo[n] for n in outputs)
                  else:
                      # Non-leaf node with unprocess outputs: stack grows
                      work.append(node.name)
                      work.extend(outputs_to_process)
          if len(work) == 0:
              return memo[node.name]
  
imports: import sys
  from coremltools import _logger
  from ..basic_graph_ops import delete_node
label_desc: Use image node_id 1 for calling a global function with example usage: _all_assert_leaves(gdict, nodename, memo) and returns: memo