code: def wait_for_errors(p, error_check):
      # Wait for errors from all the nondeterministic tasks.
      errors = []
      time_left = 100
      while time_left > 0:
          errors.extend(get_error_message(p, 1))
          if error_check(errors):
              break
          time_left -= 1
          time.sleep(1)
  
      # Make sure that enough errors came through.
      assert error_check(errors)
      return errors
  
file_path: ray/python/ray/tests/test_stress_failure.py
imports: import sys
  import time
  import numpy
  import pytest
  import ray
  import ray._private.ray_constants
  from ray._private.test_utils import get_error_message
  from ray.cluster_utils import Cluster, cluster_not_supported
label_desc: Use image node_id 6 for calling a global function with example usage: wait_for_errors(p, error_check) and returns: errors