code: def assert_threads_are_bounded(
      prev_threads: Dict[str, int], now_threads: Dict[str, int]
  ):
      """
      Asserts that the threads did not grow unexpected.
      Rule: For each (thread_name, count) in now_threads, it must either be <= the number
      in prev_threads, or in KNOWN_THREADS.
      """
      for thread_name, count in now_threads.items():
          if thread_name not in KNOWN_THREADS:
              target = prev_threads.get(thread_name, 0)
              assert count <= target, (
                  f"{thread_name} grows unexpectedly: "
                  f"expected <= {target}, got {count}. "
                  f"prev {prev_threads}, now: {now_threads}"
              )
  
file_path: ray/python/ray/tests/test_actor_bounded_threads.py
imports: import sys
  import os
  import ray
  import logging
  from typing import Dict
  from collections import Counter
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: assert_threads_are_bounded(prev_threads, now_threads) without return types