docstr: Test whether PPO can be built with all frameworks.
docstr_tok: ["Test","whether","PPO","can","be","built","with","all","frameworks","."]
code: def test_ppo_compilation_and_schedule_mixins(self):
      """Test whether PPO can be built with all frameworks."""
  
      # Build a PPOConfig object.
      config = (
          ppo.PPOConfig()
          .experimental(_enable_new_api_stack=True)
          .training(
              num_sgd_iter=2,
              # Setup lr schedule for testing lr-scheduling correctness.
              lr=[[0, 0.00001], [512, 0.0]],  # 512=4x128
              # Set entropy_coeff to a faulty value to proof that it'll get
              # overridden by the schedule below (which is expected).
              entropy_coeff=[[0, 0.1], [256, 0.0]],  # 256=2x128,
              train_batch_size=128,
          )
          .rollouts(
              num_rollout_workers=1,
              # Test with compression.
              # compress_observations=True,
              enable_connectors=True,
          )
          .callbacks(MyCallbacks)
      )
  
      num_iterations = 2
  
      for fw in framework_iterator(config, frameworks=("tf2", "torch")):
          # TODO (Kourosh) Bring back "FrozenLake-v1"
          for env in ["CartPole-v1", "Pendulum-v1", "ALE/Breakout-v5"]:
              print("Env={}".format(env))
              for lstm in [True, False]:
                  print("LSTM={}".format(lstm))
                  config.training(model=get_model_config(fw, lstm=lstm))
  
                  algo = config.build(env=env)
                  # TODO: Maybe add an API to get the Learner(s) instances within
                  #  a learner group, remote or not.
                  learner = algo.learner_group._learner
                  optim = learner.get_optimizer()
                  # Check initial LR directly set in optimizer vs the first (ts=0)
                  # value from the schedule.
                  lr = (
                      optim.param_groups[0]["lr"]
                      if fw == "torch"
                      else optim.lr
                  )
                  check(lr, config.lr[0][1])
  
                  # Check current entropy coeff value using the respective Scheduler.
                  entropy_coeff = (
                      learner.entropy_coeff_schedulers_per_module[
                          DEFAULT_POLICY_ID
                      ].get_current_value()
                  )
                  check(entropy_coeff, 0.1)
  
                  for i in range(num_iterations):
                      results = algo.train()
                      check_train_results(results)
                      print(results)
  
                  check_compute_single_action(
                      algo,
                      include_prev_action_reward=True,
                      include_state=lstm,
                  )
                  algo.stop()
  
imports: import unittest
  import numpy
  import ray
  import ray.rllib.algorithms.ppo
  from ray.rllib.algorithms.ppo.ppo import LEARNER_RESULTS_CURR_ENTROPY_COEFF_KEY
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.algorithms.ppo.tests.test_ppo import PENDULUM_FAKE_BATCH
  from ray.rllib.core.learner.learner import LEARNER_RESULTS_CURR_LR_KEY
  from ray.rllib.evaluation.postprocessing import compute_gae_for_sample_batch
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.metrics.learner_info import LEARNER_INFO
  from ray.rllib.utils.test_utils import check, check_compute_single_action, check_train_results, framework_iterator
label_desc: Use image node_id 3 for calling the TestPPO obj's underlying member method code with example usage: obj.test_ppo_compilation_and_schedule_mixins() without return types