class_docstr: This is a Ray Train-like execution flow.
  
  - We want to run 4 actors in total ("trials")
  - Each actor runs two init functions
  - We train all actors in parallel for 10 iterations
  - Errors can come up on actor construction, in the init functions,
    or during training
  - When an actor fails, restart that actor
  - When a task fails, stop actor, and restart
class_docstr_tok: ["This","is","a","Ray","Train-like","execution","flow",".","-","We","want","to","run","4","actors","in","total","(","``","trials","''",")","-","Each","actor","runs","two","init","functions","-","We","train","all","actors","in","parallel","for","10","iterations","-","Errors","can","come","up","on","actor","construction",",","in","the","init","functions",",","or","during","training","-","When","an","actor","fails",",","restart","that","actor","-","When","a","task","fails",",","stop","actor",",","and","restart"]
code: def __init__(
      self,
      actor_manager: RayActorManager,
      errors: Optional[List[str]] = None,
  ):
      self._actor_manager = actor_manager
      self._finished = False
  
      self._actors_to_run = 4
      self._tracked_actors = []
      self._actors_stopped = 0
  
      self._actors_to_replace = set()
  
      self._ready_actors = set()
      self._training_barrier = Barrier(
          max_results=self._actors_to_run,
          on_completion=self.training_barrier_completed,
      )
      self._restart_training = None
  
      self._training_iter = 0
      self._results = []
  
      self._errors = errors
  
imports: import random
  from typing import Any, List, Optional
  import pytest
  import ray
  from ray.air import ResourceRequest
  from ray.air.execution import FixedResourceManager, PlacementGroupResourceManager
  from ray.air.execution._internal import Barrier
  from ray.air.execution._internal.actor_manager import RayActorManager
  from ray.air.execution._internal.tracked_actor import TrackedActor
  from ray.exceptions import RayActorError
label_desc: Use image node_id 1 to create a new TrainFlow object  with example: obj = TrainFlow(actor_manager, errors)