docstr: Tests, whether PPO runs with different exploration setups.
docstr_tok: ["Tests",",","whether","PPO","runs","with","different","exploration","setups","."]
code: def test_ppo_exploration_setup(self):
      """Tests, whether PPO runs with different exploration setups."""
      config = (
          ppo.PPOConfig()
          .experimental(_enable_new_api_stack=True)
          .environment(
              "FrozenLake-v1",
              env_config={"is_slippery": False, "map_name": "4x4"},
          )
          .rollouts(
              # Run locally.
              num_rollout_workers=1,
              enable_connectors=True,
          )
      )
      obs = np.array(0)
  
      for _ in framework_iterator(config, frameworks=("torch", "tf2")):
          # Default Agent should be setup with StochasticSampling.
          algo = config.build()
          # explore=False, always expect the same (deterministic) action.
          a_ = algo.compute_single_action(
              obs,
              explore=False,
              prev_action=np.array(2),
              prev_reward=np.array(1.0),
          )
  
          for _ in range(50):
              a = algo.compute_single_action(
                  obs,
                  explore=False,
                  prev_action=np.array(2),
                  prev_reward=np.array(1.0),
              )
              check(a, a_)
  
          # With explore=True (default), expect stochastic actions.
          actions = []
          for _ in range(300):
              actions.append(
                  algo.compute_single_action(
                      obs,
                      prev_action=np.array(2),
                      prev_reward=np.array(1.0),
                  )
              )
          check(np.mean(actions), 1.5, atol=0.49)
          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 4 for calling the TestPPO obj's underlying member method code with example usage: obj.test_ppo_exploration_setup() without return types