code: def toposort(end_node, parents=operator.attrgetter("parents")):
      child_counts = {}
      stack = [end_node]
      while stack:
          node = stack.pop()
          if node in child_counts:
              child_counts[node] += 1
          else:
              child_counts[node] = 1
              stack.extend(parents(node))
  
      childless_nodes = [end_node]
      while childless_nodes:
          node = childless_nodes.pop()
          yield node
          for parent in parents(node):
              if child_counts[parent] == 1:
                  childless_nodes.append(parent)
              else:
                  child_counts[parent] -= 1
  
imports: import operator
  import sys
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: toposort(end_node, parents) without return types