code: def teardown_function():
      """Check if there are no children processes started by the test after it ended.
  
      Be sure to call `capture_processes` in the test.
      """
      global pool_processes
      global pool_threads
      global pools
      assert len(
          pool_processes
      ), "No processes where tracked - did the test call capture_processes?"
      pools_not_collected = [
          pool_ref() is not None for pool_ref in pools
      ]
      current_process = psutil.Process()
      children_pids = [
          process.pid for process in current_process.children()
      ]
      left = set(pool_processes).intersection(children_pids)
      assert len(left) == 0, (
          f"Pipeline-started processes left after test is finished, pids alive: {left},\n"
          f"pids started during tests: {pool_processes}.\n"
          f"Pools not collected: {sum(pools_not_collected)}"
      )
      alive_threads = [thread.is_alive() for thread in pool_threads]
      assert sum(alive_threads) == 0, (
          "Some pool related threads are left after the test finished. "
          "Started in test suite: {}, still active: {}. "
          "Active threads map in the order of creation {}".format(
              len(pool_threads), sum(alive_threads), alive_threads
          )
      )
  
file_path: DALI/dali/test/python/test_pool_utils.py
imports: import os
  import psutil
  import weakref
label_desc: Use image node_id 3 for calling a global function with example usage: teardown_function() without return types