code: def test_connectivity_on_removal(edges):
      # check that when nodes are removed in reverse topological order
      # connectivity of the DAG is maintained, i.e. remaining nodes
      # are reachable from the root.
      root = 1
      tr = Trace()
      for e1, e2 in edges:
          tr.add_edge(e1, e2)
      top_sort = tr.topological_sort()
      while top_sort:
          num_nodes = len([n for n in tr._dfs(root, set())])
          num_expected = len(top_sort)
          assert_equal(num_nodes, num_expected)
          tr.remove_node(top_sort.pop())
  
imports: import itertools
  import pytest
  from pyro.poutine import Trace
  from tests.common import assert_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_connectivity_on_removal(edges) without return types