class_docstr: Defines a configuration class from which an AlphaStar Algorithm can be built.
  
  Example:
      >>> from ray.rllib.algorithms.alpha_star import AlphaStarConfig
      >>> config = AlphaStarConfig().training(lr=0.0003, train_batch_size=512)        ...     .resources(num_gpus=4)        ...     .rollouts(num_rollout_workers=64)
      >>> print(config.to_dict()) # doctest: +SKIP
      >>> # Build a Algorithm object from the config and run 1 training iteration.
      >>> algo = config.build(env="CartPole-v1")
      >>> algo.train() # doctest: +SKIP
  
  Example:
      >>> from ray.rllib.algorithms.alpha_star import AlphaStarConfig
      >>> from ray import air
      >>> from ray import tune
      >>> config = AlphaStarConfig()
      >>> # Print out some default values.
      >>> print(config.vtrace) # doctest: +SKIP
      >>> # Update the config object.
      >>> config.training(lr=tune.grid_search([0.0001, 0.0003]), grad_clip=20.0)
      >>> # Set the config object's env.
      >>> config.environment(env="CartPole-v1")
      >>> # Use to_dict() to get the old-style python config dict
      >>> # when running with tune.
      >>> tune.Tuner( # doctest: +SKIP
      ...     "AlphaStar",
      ...     run_config=air.RunConfig(stop={"episode_reward_mean": 200}),
      ...     param_space=config.to_dict(),
      ... ).fit()
class_docstr_tok: ["Defines","a","configuration","class","from","which","an","AlphaStar","Algorithm","can","be","built",".","Example",":",">",">",">","from","ray.rllib.algorithms.alpha_star","import","AlphaStarConfig",">",">",">","config","=","AlphaStarConfig","(",")",".training","(","lr=0.0003",",","train_batch_size=512",")","...",".resources","(","num_gpus=4",")","...",".rollouts","(","num_rollout_workers=64",")",">",">",">","print","(","config.to_dict","(",")",")","#","doctest",":","+SKIP",">",">",">","#","Build","a","Algorithm","object","from","the","config","and","run","1","training","iteration",".",">",">",">","algo","=","config.build","(","env=","''","CartPole-v1","''",")",">",">",">","algo.train","(",")","#","doctest",":","+SKIP","Example",":",">",">",">","from","ray.rllib.algorithms.alpha_star","import","AlphaStarConfig",">",">",">","from","ray","import","air",">",">",">","from","ray","import","tune",">",">",">","config","=","AlphaStarConfig","(",")",">",">",">","#","Print","out","some","default","values",".",">",">",">","print","(","config.vtrace",")","#","doctest",":","+SKIP",">",">",">","#","Update","the","config","object",".",">",">",">","config.training","(","lr=tune.grid_search","(","[","0.0001",",","0.0003","]",")",",","grad_clip=20.0",")",">",">",">","#","Set","the","config","object","'s","env",".",">",">",">","config.environment","(","env=","''","CartPole-v1","''",")",">",">",">","#","Use","to_dict","(",")","to","get","the","old-style","python","config","dict",">",">",">","#","when","running","with","tune",".",">",">",">","tune.Tuner","(","#","doctest",":","+SKIP","...","``","AlphaStar","''",",","...","run_config=air.RunConfig","(","stop=","{","``","episode_reward_mean","''",":","200","}",")",",","...","param_space=config.to_dict","(",")",",","...",")",".fit","(",")"]
docstr: Sets the training related configuration.
  
  Args:
      replay_buffer_capacity: This is num batches held at any time for each
          policy.
      replay_buffer_replay_ratio: For example, ratio=0.2 -> 20% of samples in
          each train batch are old (replayed) ones.
      timeout_s_sampler_manager: Timeout to use for `ray.wait()` when waiting for
          samplers to have placed new data into the buffers. If no samples are
          ready within the timeout, the buffers used for mixin-sampling will
          return only older samples.
      timeout_s_learner_manager: Timeout to use for `ray.wait()` when waiting for
          the policy learner actors to have performed an update and returned
          learning stats. If no learner actors have produced any learning
          results in the meantime, their learner-stats in the results will be
          empty for that iteration.
      max_requests_in_flight_per_sampler_worker: Maximum number of ray remote
          calls that can be run in parallel for each sampler worker. This is
          particularly important when dealing with many sampler workers or
          sample batches that are large, and when could potentially fill up
          the object store.
      max_requests_in_flight_per_learner_worker: Maximum number of ray remote
          calls that can be run in parallel for each learner worker. This is
          important to tune when dealing with many learner workers so that the
          object store doesn't fill up and so that learner actors don't become
          backed up with too many requests that could become stale if not
          attended to in a timely manner.
      league_builder_config: League-building config dict.
          The dict Must contain a `type` key indicating the LeagueBuilder class
          to be used for league building logic. All other keys (that are not
          `type`) will be used as constructor kwargs on the given class to
          construct the LeagueBuilder instance. See the
          `ray.rllib.algorithms.alpha_star.league_builder::AlphaStarLeagueBuilder`
          (used by default by this algo) as an example.
      max_num_policies_to_train: The maximum number of trainable policies for this
          Algorithm. Each trainable policy will exist as a independent remote
          actor, co-located with a replay buffer. This is besides its existence
          inside the RolloutWorkers for training and evaluation. Set to None for
          automatically inferring this value from the number of trainable
          policies found in the `multiagent` config.
  
  Returns:
      This updated AlgorithmConfig object.
docstr_tok: ["Sets","the","training","related","configuration",".","Args",":","replay_buffer_capacity",":","This","is","num","batches","held","at","any","time","for","each","policy",".","replay_buffer_replay_ratio",":","For","example",",","ratio=0.2","-",">","20","%","of","samples","in","each","train","batch","are","old","(","replayed",")","ones",".","timeout_s_sampler_manager",":","Timeout","to","use","for","`","ray.wait","(",")","`","when","waiting","for","samplers","to","have","placed","new","data","into","the","buffers",".","If","no","samples","are","ready","within","the","timeout",",","the","buffers","used","for","mixin-sampling","will","return","only","older","samples",".","timeout_s_learner_manager",":","Timeout","to","use","for","`","ray.wait","(",")","`","when","waiting","for","the","policy","learner","actors","to","have","performed","an","update","and","returned","learning","stats",".","If","no","learner","actors","have","produced","any","learning","results","in","the","meantime",",","their","learner-stats","in","the","results","will","be","empty","for","that","iteration",".","max_requests_in_flight_per_sampler_worker",":","Maximum","number","of","ray","remote","calls","that","can","be","run","in","parallel","for","each","sampler","worker",".","This","is","particularly","important","when","dealing","with","many","sampler","workers","or","sample","batches","that","are","large",",","and","when","could","potentially","fill","up","the","object","store",".","max_requests_in_flight_per_learner_worker",":","Maximum","number","of","ray","remote","calls","that","can","be","run","in","parallel","for","each","learner","worker",".","This","is","important","to","tune","when","dealing","with","many","learner","workers","so","that","the","object","store","does","n't","fill","up","and","so","that","learner","actors","do","n't","become","backed","up","with","too","many","requests","that","could","become","stale","if","not","attended","to","in","a","timely","manner",".","league_builder_config",":","League-building","config","dict",".","The","dict","Must","contain","a","`","type","`","key","indicating","the","LeagueBuilder","class","to","be","used","for","league","building","logic",".","All","other","keys","(","that","are","not","`","type","`",")","will","be","used","as","constructor","kwargs","on","the","given","class","to","construct","the","LeagueBuilder","instance",".","See","the","`","ray.rllib.algorithms.alpha_star.league_builder",":",":AlphaStarLeagueBuilder","`","(","used","by","default","by","this","algo",")","as","an","example",".","max_num_policies_to_train",":","The","maximum","number","of","trainable","policies","for","this","Algorithm",".","Each","trainable","policy","will","exist","as","a","independent","remote","actor",",","co-located","with","a","replay","buffer",".","This","is","besides","its","existence","inside","the","RolloutWorkers","for","training","and","evaluation",".","Set","to","None","for","automatically","inferring","this","value","from","the","number","of","trainable","policies","found","in","the","`","multiagent","`","config",".","Returns",":","This","updated","AlgorithmConfig","object","."]
code: def training(
      self,
      *,
      replay_buffer_capacity: Optional[int] = NotProvided,
      replay_buffer_replay_ratio: Optional[float] = NotProvided,
      max_requests_in_flight_per_sampler_worker: Optional[
          int
      ] = NotProvided,
      max_requests_in_flight_per_learner_worker: Optional[
          int
      ] = NotProvided,
      timeout_s_sampler_manager: Optional[float] = NotProvided,
      timeout_s_learner_manager: Optional[float] = NotProvided,
      league_builder_config: Optional[Dict[str, Any]] = NotProvided,
      max_num_policies_to_train: Optional[int] = NotProvided,
      **kwargs,
  ) -> "AlphaStarConfig":
      """Sets the training related configuration.
  
      Args:
          replay_buffer_capacity: This is num batches held at any time for each
              policy.
          replay_buffer_replay_ratio: For example, ratio=0.2 -> 20% of samples in
              each train batch are old (replayed) ones.
          timeout_s_sampler_manager: Timeout to use for `ray.wait()` when waiting for
              samplers to have placed new data into the buffers. If no samples are
              ready within the timeout, the buffers used for mixin-sampling will
              return only older samples.
          timeout_s_learner_manager: Timeout to use for `ray.wait()` when waiting for
              the policy learner actors to have performed an update and returned
              learning stats. If no learner actors have produced any learning
              results in the meantime, their learner-stats in the results will be
              empty for that iteration.
          max_requests_in_flight_per_sampler_worker: Maximum number of ray remote
              calls that can be run in parallel for each sampler worker. This is
              particularly important when dealing with many sampler workers or
              sample batches that are large, and when could potentially fill up
              the object store.
          max_requests_in_flight_per_learner_worker: Maximum number of ray remote
              calls that can be run in parallel for each learner worker. This is
              important to tune when dealing with many learner workers so that the
              object store doesn't fill up and so that learner actors don't become
              backed up with too many requests that could become stale if not
              attended to in a timely manner.
          league_builder_config: League-building config dict.
              The dict Must contain a `type` key indicating the LeagueBuilder class
              to be used for league building logic. All other keys (that are not
              `type`) will be used as constructor kwargs on the given class to
              construct the LeagueBuilder instance. See the
              `ray.rllib.algorithms.alpha_star.league_builder::AlphaStarLeagueBuilder`
              (used by default by this algo) as an example.
          max_num_policies_to_train: The maximum number of trainable policies for this
              Algorithm. Each trainable policy will exist as a independent remote
              actor, co-located with a replay buffer. This is besides its existence
              inside the RolloutWorkers for training and evaluation. Set to None for
              automatically inferring this value from the number of trainable
              policies found in the `multiagent` config.
  
      Returns:
          This updated AlgorithmConfig object.
      """
      # Pass kwargs onto super's `training()` method.
      super().training(**kwargs)
  
      # TODO: Unify the buffer API, then clean up our existing
      #  implementations of different buffers.
      if replay_buffer_capacity is not NotProvided:
          self.replay_buffer_capacity = replay_buffer_capacity
      if replay_buffer_replay_ratio is not NotProvided:
          self.replay_buffer_replay_ratio = replay_buffer_replay_ratio
      if timeout_s_sampler_manager is not NotProvided:
          self.timeout_s_sampler_manager = timeout_s_sampler_manager
      if timeout_s_learner_manager is not NotProvided:
          self.timeout_s_learner_manager = timeout_s_learner_manager
      if league_builder_config is not NotProvided:
          # Override entire `league_builder_config` if `type` key changes.
          # Update, if `type` key remains the same or is not specified.
          new_league_builder_config = deep_update(
              {"league_builder_config": self.league_builder_config},
              {"league_builder_config": league_builder_config},
              False,
              ["league_builder_config"],
              ["league_builder_config"],
          )
          self.league_builder_config = new_league_builder_config[
              "league_builder_config"
          ]
      if max_num_policies_to_train is not NotProvided:
          self.max_num_policies_to_train = max_num_policies_to_train
      if max_requests_in_flight_per_sampler_worker is not NotProvided:
          self.max_requests_in_flight_per_sampler_worker = (
              max_requests_in_flight_per_sampler_worker
          )
      if max_requests_in_flight_per_learner_worker is not NotProvided:
          self.max_requests_in_flight_per_learner_worker = (
              max_requests_in_flight_per_learner_worker
          )
  
      return self
  
imports: from typing import Any, Dict, Optional, Type, Union
  import gymnasium
  import tree
  from rllib_alpha_star.alpha_star.distributed_learners import DistributedLearners
  from rllib_alpha_star.alpha_star.league_builder import AlphaStarLeagueBuilder
  import ray
  import ray.rllib.algorithms.appo.appo
  from ray.actor import ActorHandle
  from ray.rllib.algorithms.algorithm import Algorithm
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
  from ray.rllib.evaluation.rollout_worker import RolloutWorker
  from ray.rllib.execution.buffers.mixin_replay_buffer import MixInMultiAgentReplayBuffer
  from ray.rllib.execution.parallel_requests import AsyncRequestsManager
  from ray.rllib.policy.policy import Policy, PolicySpec
  from ray.rllib.policy.sample_batch import MultiAgentBatch
  from ray.rllib.utils import deep_update
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.from_config import from_config
  from ray.rllib.utils.metrics import LAST_TARGET_UPDATE_TS, LEARN_ON_BATCH_TIMER, NUM_AGENT_STEPS_SAMPLED, NUM_AGENT_STEPS_TRAINED, NUM_ENV_STEPS_SAMPLED, NUM_TARGET_UPDATES, SAMPLE_TIMER, SYNCH_WORKER_WEIGHTS_TIMER, TARGET_NET_UPDATE_TIMER
  from ray.rllib.utils.metrics.learner_info import LEARNER_STATS_KEY
  from ray.rllib.utils.typing import PartialAlgorithmConfigDict, PolicyID, PolicyState, ResultDict
  from ray.tune.execution.placement_groups import PlacementGroupFactory
  from ray.util.timer import _Timer
label_desc: Use image node_id 2 for calling the AlphaStarConfig obj's underlying member method code with example usage: obj.training() and returns: self