class_docstr: Specify the compute strategy for a Dataset transform.
  
  ActorPoolStrategy specifies that an autoscaling pool of actors should be used
  for a given Dataset transform. This is useful for stateful setup of callable
  classes.
  
  For a fixed-sized pool of size ``n``, specify ``compute=ActorPoolStrategy(size=n)``.
  To autoscale from ``m`` to ``n`` actors, specify
  ``ActorPoolStrategy(min_size=m, max_size=n)``.
  
  To increase opportunities for pipelining task dependency prefetching with
  computation and avoiding actor startup delays, set max_tasks_in_flight_per_actor
  to 2 or greater; to try to decrease the delay due to queueing of tasks on the worker
  actors, set max_tasks_in_flight_per_actor to 1.
docstr: Construct ActorPoolStrategy for a Dataset transform.
  
  Args:
      size: Specify a fixed size actor pool of this size. It is an error to
          specify both `size` and `min_size` or `max_size`.
      min_size: The minimize size of the actor pool.
      max_size: The maximum size of the actor pool.
      max_tasks_in_flight_per_actor: The maximum number of tasks to concurrently
          send to a single actor worker. Increasing this will increase
          opportunities for pipelining task dependency prefetching with
          computation and avoiding actor startup delays, but will also increase
          queueing delay.
docstr_tok: ["Construct","ActorPoolStrategy","for","a","Dataset","transform",".","Args",":","size",":","Specify","a","fixed","size","actor","pool","of","this","size",".","It","is","an","error","to","specify","both","`","size","`","and","`","min_size","`","or","`","max_size","`",".","min_size",":","The","minimize","size","of","the","actor","pool",".","max_size",":","The","maximum","size","of","the","actor","pool",".","max_tasks_in_flight_per_actor",":","The","maximum","number","of","tasks","to","concurrently","send","to","a","single","actor","worker",".","Increasing","this","will","increase","opportunities","for","pipelining","task","dependency","prefetching","with","computation","and","avoiding","actor","startup","delays",",","but","will","also","increase","queueing","delay","."]
code: def __init__(
      self,
      # Deprecated: kwargs will be required for all args in a future release.
      legacy_min_size: Optional[int] = None,
      legacy_max_size: Optional[int] = None,
      *,
      size: Optional[int] = None,
      min_size: Optional[int] = None,
      max_size: Optional[int] = None,
      max_tasks_in_flight_per_actor: Optional[int] = None,
  ):
      """Construct ActorPoolStrategy for a Dataset transform.
  
      Args:
          size: Specify a fixed size actor pool of this size. It is an error to
              specify both `size` and `min_size` or `max_size`.
          min_size: The minimize size of the actor pool.
          max_size: The maximum size of the actor pool.
          max_tasks_in_flight_per_actor: The maximum number of tasks to concurrently
              send to a single actor worker. Increasing this will increase
              opportunities for pipelining task dependency prefetching with
              computation and avoiding actor startup delays, but will also increase
              queueing delay.
      """
      if legacy_min_size is not None or legacy_max_size is not None:
          raise ValueError(
              "In Ray 2.5, ActorPoolStrategy requires min_size and "
              "max_size to be explicit kwargs."
          )
      if size:
          if size < 1:
              raise ValueError("size must be >= 1", size)
          if max_size is not None or min_size is not None:
              raise ValueError(
                  "min_size and max_size cannot be set at the same time as `size`"
              )
          min_size = size
          max_size = size
      if min_size is not None and min_size < 1:
          raise ValueError("min_size must be >= 1", min_size)
      if max_size is not None:
          if min_size is None:
              min_size = 1  # Legacy default.
          if min_size > max_size:
              raise ValueError(
                  "min_size must be <= max_size", min_size, max_size
              )
      if (
          max_tasks_in_flight_per_actor is not None
          and max_tasks_in_flight_per_actor < 1
      ):
          raise ValueError(
              "max_tasks_in_flight_per_actor must be >= 1, got: ",
              max_tasks_in_flight_per_actor,
          )
      self.min_size = min_size or 1
      self.max_size = max_size or float("inf")
      self.max_tasks_in_flight_per_actor = max_tasks_in_flight_per_actor
      self.num_workers = 0
      self.ready_to_total_workers_ratio = 0.8
  
imports: import collections
  import logging
  import math
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, TypeVar, Union
  import ray
  from ray.data._internal.block_list import BlockList
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
  from ray.data._internal.execution.interfaces import TaskContext
  from ray.data._internal.progress_bar import ProgressBar
  from ray.data._internal.remote_fn import cached_remote_fn
  from ray.data.block import Block, BlockAccessor, BlockExecStats, BlockMetadata, BlockPartition, CallableClass, UserDefinedFunction
  from ray.data.context import DataContext
  from ray.types import ObjectRef
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 1 to create a new ActorPoolStrategy object from inherited base classes: ComputeStrategy with example: obj = ActorPoolStrategy(legacy_min_size, legacy_max_size)