class_docstr: Defines a configuration class from which an AlphaZero Algorithm can be built.
  
  Example:
      >>> from rllib_alpha_zero.alpha_zero import AlphaZeroConfig
      >>> config = AlphaZeroConfig()   # doctest: +SKIP
      >>> config = config.training(sgd_minibatch_size=256)   # doctest: +SKIP
      >>> config = config..resources(num_gpus=0)   # doctest: +SKIP
      >>> config = config..rollouts(num_rollout_workers=4)   # doctest: +SKIP
      >>> print(config.to_dict()) # doctest: +SKIP
      >>> # Build a Algorithm object from the config and run 1 training iteration.
      >>> algo = config.build(env="CartPole-v1")  # doctest: +SKIP
      >>> algo.train() # doctest: +SKIP
  
  Example:
      >>> from rllib_alpha_zero.alpha_zero import AlphaZeroConfig
      >>> from ray import air
      >>> from ray import tune
      >>> config = AlphaZeroConfig()
      >>> # Print out some default values.
      >>> print(config.shuffle_sequences) # doctest: +SKIP
      >>> # Update the config object.
      >>> config.training(lr=tune.grid_search([0.001, 0.0001]))  # doctest: +SKIP
      >>> # Set the config object's env.
      >>> config.environment(env="CartPole-v1")   # doctest: +SKIP
      >>> # Use to_dict() to get the old-style python config dict
      >>> # when running with tune.
      >>> tune.Tuner( # doctest: +SKIP
      ...     "AlphaZero",
      ...     run_config=air.RunConfig(stop={"episode_reward_mean": 200}),
      ...     param_space=config.to_dict(),
      ... ).fit()
docstr: Sets the training related configuration.
  
  Args:
      sgd_minibatch_size: Total SGD batch size across all devices for SGD.
      shuffle_sequences: Whether to shuffle sequences in the batch when training
          (recommended).
      num_sgd_iter: Number of SGD iterations in each outer loop.
      replay_buffer_config: Replay buffer config.
          Examples:
          {
          "_enable_replay_buffer_api": True,
          "type": "MultiAgentReplayBuffer",
          "learning_starts": 1000,
          "capacity": 50000,
          "replay_sequence_length": 1,
          }
          - OR -
          {
          "_enable_replay_buffer_api": True,
          "type": "MultiAgentPrioritizedReplayBuffer",
          "capacity": 50000,
          "prioritized_replay_alpha": 0.6,
          "prioritized_replay_beta": 0.4,
          "prioritized_replay_eps": 1e-6,
          "replay_sequence_length": 1,
          }
          - Where -
          prioritized_replay_alpha: Alpha parameter controls the degree of
          prioritization in the buffer. In other words, when a buffer sample has
          a higher temporal-difference error, with how much more probability
          should it drawn to use to update the parametrized Q-network. 0.0
          corresponds to uniform probability. Setting much above 1.0 may quickly
          result as the sampling distribution could become heavily “pointy” with
          low entropy.
          prioritized_replay_beta: Beta parameter controls the degree of
          importance sampling which suppresses the influence of gradient updates
          from samples that have higher probability of being sampled via alpha
          parameter and the temporal-difference error.
          prioritized_replay_eps: Epsilon parameter sets the baseline probability
          for sampling so that when the temporal-difference error of a sample is
          zero, there is still a chance of drawing the sample.
      lr_schedule: Learning rate schedule. In the format of
          [[timestep, lr-value], [timestep, lr-value], ...]
          Intermediary timesteps will be assigned to interpolated learning rate
          values. A schedule should normally start from timestep 0.
      vf_share_layers: Share layers for value function. If you set this to True,
          it's important to tune vf_loss_coeff.
      mcts_config: MCTS specific settings.
      ranked_rewards: Settings for the ranked reward (r2) algorithm
          from: https://arxiv.org/pdf/1807.01672.pdf
      num_steps_sampled_before_learning_starts: Number of timesteps to collect
          from rollout workers before we start sampling from replay buffers for
          learning. Whether we count this in agent steps  or environment steps
          depends on config.multi_agent(count_steps_by=..).
  
  Returns:
      This updated AlgorithmConfig object.
code: def training(
      self,
      *,
      sgd_minibatch_size: Optional[int] = NotProvided,
      shuffle_sequences: Optional[bool] = NotProvided,
      num_sgd_iter: Optional[int] = NotProvided,
      replay_buffer_config: Optional[dict] = NotProvided,
      lr_schedule: Optional[
          List[List[Union[int, float]]]
      ] = NotProvided,
      vf_share_layers: Optional[bool] = NotProvided,
      mcts_config: Optional[dict] = NotProvided,
      ranked_rewards: Optional[dict] = NotProvided,
      num_steps_sampled_before_learning_starts: Optional[
          int
      ] = NotProvided,
      **kwargs,
  ) -> "AlphaZeroConfig":
      """Sets the training related configuration.
  
      Args:
          sgd_minibatch_size: Total SGD batch size across all devices for SGD.
          shuffle_sequences: Whether to shuffle sequences in the batch when training
              (recommended).
          num_sgd_iter: Number of SGD iterations in each outer loop.
          replay_buffer_config: Replay buffer config.
              Examples:
              {
              "_enable_replay_buffer_api": True,
              "type": "MultiAgentReplayBuffer",
              "learning_starts": 1000,
              "capacity": 50000,
              "replay_sequence_length": 1,
              }
              - OR -
              {
              "_enable_replay_buffer_api": True,
              "type": "MultiAgentPrioritizedReplayBuffer",
              "capacity": 50000,
              "prioritized_replay_alpha": 0.6,
              "prioritized_replay_beta": 0.4,
              "prioritized_replay_eps": 1e-6,
              "replay_sequence_length": 1,
              }
              - Where -
              prioritized_replay_alpha: Alpha parameter controls the degree of
              prioritization in the buffer. In other words, when a buffer sample has
              a higher temporal-difference error, with how much more probability
              should it drawn to use to update the parametrized Q-network. 0.0
              corresponds to uniform probability. Setting much above 1.0 may quickly
              result as the sampling distribution could become heavily “pointy” with
              low entropy.
              prioritized_replay_beta: Beta parameter controls the degree of
              importance sampling which suppresses the influence of gradient updates
              from samples that have higher probability of being sampled via alpha
              parameter and the temporal-difference error.
              prioritized_replay_eps: Epsilon parameter sets the baseline probability
              for sampling so that when the temporal-difference error of a sample is
              zero, there is still a chance of drawing the sample.
          lr_schedule: Learning rate schedule. In the format of
              [[timestep, lr-value], [timestep, lr-value], ...]
              Intermediary timesteps will be assigned to interpolated learning rate
              values. A schedule should normally start from timestep 0.
          vf_share_layers: Share layers for value function. If you set this to True,
              it's important to tune vf_loss_coeff.
          mcts_config: MCTS specific settings.
          ranked_rewards: Settings for the ranked reward (r2) algorithm
              from: https://arxiv.org/pdf/1807.01672.pdf
          num_steps_sampled_before_learning_starts: Number of timesteps to collect
              from rollout workers before we start sampling from replay buffers for
              learning. Whether we count this in agent steps  or environment steps
              depends on config.multi_agent(count_steps_by=..).
  
      Returns:
          This updated AlgorithmConfig object.
      """
      # Pass kwargs onto super's `training()` method.
      super().training(**kwargs)
  
      if sgd_minibatch_size is not NotProvided:
          self.sgd_minibatch_size = sgd_minibatch_size
      if shuffle_sequences is not NotProvided:
          self.shuffle_sequences = shuffle_sequences
      if num_sgd_iter is not NotProvided:
          self.num_sgd_iter = num_sgd_iter
      if replay_buffer_config is not NotProvided:
          self.replay_buffer_config = replay_buffer_config
      if lr_schedule is not NotProvided:
          self.lr_schedule = lr_schedule
      if vf_share_layers is not NotProvided:
          self.vf_share_layers = vf_share_layers
      if mcts_config is not NotProvided:
          self.mcts_config = mcts_config
      if ranked_rewards is not NotProvided:
          self.ranked_rewards.update(ranked_rewards)
      if num_steps_sampled_before_learning_starts is not NotProvided:
          self.num_steps_sampled_before_learning_starts = (
              num_steps_sampled_before_learning_starts
          )
  
      return self
  
imports: import logging
  from typing import List, Optional, Type, Union
  from rllib_alpha_zero.alpha_zero.alpha_zero_policy import AlphaZeroPolicy
  from rllib_alpha_zero.alpha_zero.mcts import MCTS
  from rllib_alpha_zero.alpha_zero.ranked_rewards import get_r2_env_wrapper
  from ray.rllib.algorithms.algorithm import Algorithm
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.execution.rollout_ops import synchronous_parallel_sample
  from ray.rllib.execution.train_ops import multi_gpu_train_one_step, train_one_step
  from ray.rllib.models.catalog import ModelCatalog
  from ray.rllib.models.modelv2 import restore_original_dimensions
  from ray.rllib.models.torch.torch_action_dist import TorchCategorical
  from ray.rllib.policy.policy import Policy
  from ray.rllib.policy.sample_batch import concat_samples
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.deprecation import DEPRECATED_VALUE
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.metrics import NUM_AGENT_STEPS_SAMPLED, NUM_ENV_STEPS_SAMPLED, SAMPLE_TIMER, SYNCH_WORKER_WEIGHTS_TIMER
  from ray.rllib.utils.replay_buffers.utils import validate_buffer_config
  from ray.rllib.utils.typing import ResultDict
label_desc: Use image node_id 2 for calling the AlphaZeroConfig obj's underlying member method code with example usage: obj.training() and returns: self