code: def assert_topological_sort(dsk, order):
      dependencies, dependents = get_deps(dsk)
      num_needed = {k: len(dependencies[k]) for k in dsk}
      for k in sorted(dsk, key=order.__getitem__):
          assert num_needed[k] == 0
          for dep in dependents[k]:
              num_needed[dep] -= 1
  
imports: from __future__ import annotations
  import inspect
  import pytest
  import dask
  from dask import delayed
  from dask.base import collections_to_dsk, key_split, visualize_dsk
  from dask.core import get_deps
  from dask.order import _connecting_to_roots, diagnostics, ndependencies, order
  from dask.utils_test import add, inc
label_desc: Use image node_id 42 for calling a global function with example usage: assert_topological_sort(dsk, order) without return types