class_docstr: Tests for RE3 exploration algorithm.
class_docstr_tok: ["Tests","for","RE3","exploration","algorithm","."]
docstr: Tests RE3 for PPO and SAC.
  
  Both the on-policy and off-policy setups are validated.
docstr_tok: ["Tests","RE3","for","PPO","and","SAC",".","Both","the","on-policy","and","off-policy","setups","are","validated","."]
code: def run_re3(self, rl_algorithm):
      """Tests RE3 for PPO and SAC.
  
      Both the on-policy and off-policy setups are validated.
      """
      if rl_algorithm == "PPO":
          # We need to disable the RLModule / Learner API here, since this test is
          # overfitted to the ModelV2 API stack. The random encoder is based on
          # ModelV2 stack.
          config = ppo.PPOConfig()
          algo_cls = ppo.PPO
          beta_schedule = "constant"
      elif rl_algorithm == "SAC":
          config = sac.SACConfig()
          algo_cls = sac.SAC
          beta_schedule = "linear_decay"
  
      config = config.to_dict()
  
      class RE3Callbacks(RE3UpdateCallbacks, config["callbacks"]):
          pass
  
      config["env"] = "Pendulum-v1"
      config["callbacks"] = RE3Callbacks
      config["exploration_config"] = {
          "type": "RE3",
          "embeds_dim": 128,
          "beta_schedule": beta_schedule,
          "sub_exploration": {
              "type": "StochasticSampling",
          },
      }
  
      num_iterations = 60
      for _ in framework_iterator(
          config, frameworks=("tf", "tf2"), session=True
      ):
          algo = algo_cls(config=config)
          learnt = False
          for i in range(num_iterations):
              result = algo.train()
              print(result)
              if result["episode_reward_max"] > -900.0:
                  print("Reached goal after {} iters!".format(i))
                  learnt = True
                  break
          algo.stop()
          self.assertTrue(learnt)
  
file_path: ray/python/ray/rllib/utils/exploration/tests/test_random_encoder.py
imports: import sys
  import unittest
  import pytest
  import ray
  from ray.rllib.utils.test_utils import framework_iterator
  import ray.rllib.algorithms.ppo
  import ray.rllib.algorithms.sac
  from ray.rllib.algorithms.callbacks import RE3UpdateCallbacks
label_desc: Use image node_id 3 for calling the TestRE3 obj's underlying member method code with example usage: obj.run_re3(rl_algorithm) without return types