code: def check_refcounts(expected, timeout=10):
      start = time.time()
      while True:
          try:
              _check_refcounts(expected)
              break
          except AssertionError as e:
              if time.time() - start > timeout:
                  raise e
              else:
                  time.sleep(0.1)
  
imports: import copy
  import logging
  import os
  import sys
  import time
  import numpy
  import pytest
  import ray
  import ray._private.gcs_utils
  import ray.cluster_utils
  from ray._private.test_utils import SignalActor, convert_actor_state, kill_actor_and_wait_for_failure, put_object, wait_for_condition, skip_flaky_core_test_premerge
label_desc: Use image node_id 4 for calling a global function with example usage: check_refcounts(expected, timeout) without return types