code: def wait_for_restore(num_restarting_allowed=0):
      """Wait for Ray actor fault tolerence to restore all failed workers.
  
      Args:
          num_restarting_allowed: Number of actors that are allowed to be
              in "RESTARTING" state. This is because some actors may
              hang in __init__().
      """
      while True:
          states = [
              a["state"]
              for a in list_actors(
                  filters=[
                      (
                          "class_name",
                          "=",
                          "ForwardHealthCheckToEnvWorker",
                      )
                  ]
              )
          ]
          finished = True
          for s in states:
              # Wait till all actors are either "ALIVE" (restored),
              # or "DEAD" (cancelled. these actors are from other
              # finished test cases) or "RESTARTING" (being restored).
              if s not in ["ALIVE", "DEAD", "RESTARTING"]:
                  finished = False
                  break
  
          restarting = [s for s in states if s == "RESTARTING"]
          if len(restarting) > num_restarting_allowed:
              finished = False
  
          print("waiting ... ", states)
          if finished:
              break
          # Otherwise, wait a bit.
          time.sleep(0.5)
  
imports: from collections import defaultdict
  import gymnasium
  import numpy
  import time
  import unittest
  import ray
  from ray.util.state import list_actors
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.algorithms.dqn.dqn import DQNConfig
  from ray.rllib.algorithms.impala import ImpalaConfig
  from ray.rllib.algorithms.pg import PGConfig
  from ray.rllib.algorithms.pg.pg_tf_policy import PGTF2Policy
  from ray.rllib.algorithms.pg.pg_torch_policy import PGTorchPolicy
  from ray.rllib.algorithms.ppo import PPOConfig
  from ray.rllib.env.multi_agent_env import make_multi_agent
  from ray.rllib.evaluation.rollout_worker import RolloutWorker
  from ray.rllib.examples.env.random_env import RandomEnv
  from ray.rllib.utils.test_utils import framework_iterator
  from ray.tune.registry import register_env
label_desc: Use image node_id 1 for calling a global function with example usage: wait_for_restore(num_restarting_allowed) without return types