docstr: This test will test env runner in the game of GuessTheNumberGame.
  
  The policies are chosen to be deterministic, so that we can test for an
  expected reward. Agent 1 will always pick 1, and agent 2 will always guess that
  the picked number is higher than 1. The game will end when the picked number is
  1, and agent 1 will win. The reward will be 100 for winning, and 1 for each
  step that the game is dragged on for. So the expected reward for agent 1 is 100
  + 19 = 119. 19 is the number of steps that the game will last for agent 1
  before it wins or loses.
docstr_tok: ["This","test","will","test","env","runner","in","the","game","of","GuessTheNumberGame",".","The","policies","are","chosen","to","be","deterministic",",","so","that","we","can","test","for","an","expected","reward",".","Agent","1","will","always","pick","1",",","and","agent","2","will","always","guess","that","the","picked","number","is","higher","than","1",".","The","game","will","end","when","the","picked","number","is","1",",","and","agent","1","will","win",".","The","reward","will","be","100","for","winning",",","and","1","for","each","step","that","the","game","is","dragged","on","for",".","So","the","expected","reward","for","agent","1","is","100","+","19","=","119",".","19","is","the","number","of","steps","that","the","game","will","last","for","agent","1","before","it","wins","or","loses","."]
code: def test_guess_the_number_multi_agent(self):
      """This test will test env runner in the game of GuessTheNumberGame.
  
      The policies are chosen to be deterministic, so that we can test for an
      expected reward. Agent 1 will always pick 1, and agent 2 will always guess that
      the picked number is higher than 1. The game will end when the picked number is
      1, and agent 1 will win. The reward will be 100 for winning, and 1 for each
      step that the game is dragged on for. So the expected reward for agent 1 is 100
      + 19 = 119. 19 is the number of steps that the game will last for agent 1
      before it wins or loses.
      """
  
      register_env(
          "env_under_test", lambda config: GuessTheNumberGame(config)
      )
  
      def mapping_fn(agent_id, *args, **kwargs):
          return "pol1" if agent_id == 0 else "pol2"
  
      class PickOne(RandomPolicy):
          """This policy will always pick 1."""
  
          def compute_actions(
              self,
              obs_batch,
              state_batches=None,
              prev_action_batch=None,
              prev_reward_batch=None,
              **kwargs,
          ):
              return [np.array([2, 1])] * len(obs_batch), [], {}
  
      class GuessHigherThanOne(RandomPolicy):
          """This policy will guess that the picked number is higher than 1."""
  
          def compute_actions(
              self,
              obs_batch,
              state_batches=None,
              prev_action_batch=None,
              prev_reward_batch=None,
              **kwargs,
          ):
              return [np.array([1, 1])] * len(obs_batch), [], {}
  
      config = (
          PPOConfig()
          .framework("torch")
          .environment("env_under_test", disable_env_checking=True)
          .rollouts(
              num_envs_per_worker=1,
              num_rollout_workers=0,
              # Enable EnvRunnerV2.
              enable_connectors=True,
              rollout_fragment_length=100,
          )
          .multi_agent(
              # this makes it independent of neural networks
              policies={
                  "pol1": PolicySpec(policy_class=PickOne),
                  "pol2": PolicySpec(policy_class=GuessHigherThanOne),
              },
              policy_mapping_fn=mapping_fn,
          )
          # TODO (Kourosh): We need to later create the PickOne and
          # GuessHigherThanOne RLModules but for now, the policy only needs a
          # placeholder RLModule, since the compute_actions() method is
          # directly overridden in the policy class.
          .rl_module(
              rl_module_spec=MultiAgentRLModuleSpec(
                  module_specs={
                      "pol1": SingleAgentRLModuleSpec(
                          module_class=RandomRLModule
                      ),
                      "pol2": SingleAgentRLModuleSpec(
                          module_class=RandomRLModule
                      ),
                  }
              ),
          )
          .debugging(seed=42)
      )
  
      algo = PPO(config)
  
      rollout_worker = algo.workers.local_worker()
      sample_batch = rollout_worker.sample()
      pol1_batch = sample_batch.policy_batches["pol1"]
  
      # reward should be 100 (for winning) + 19 (for dragging the game for 19 steps)
      check(
          pol1_batch["rewards"],
          119 * np.ones_like(pol1_batch["rewards"]),
      )
      # check if pol1 only has one timestep of transition informatio per each episode
      check(len(set(pol1_batch["eps_id"])), len(pol1_batch["eps_id"]))
      # check if pol2 has 19 timesteps of transition information per each episode
      pol2_batch = sample_batch.policy_batches["pol2"]
      check(
          len(set(pol2_batch["eps_id"])) * 19, len(pol2_batch["eps_id"])
      )
  
imports: import unittest
  import numpy
  import ray
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.algorithms.ppo import PPO, PPOConfig
  from ray.rllib.connectors.connector import ActionConnector, ConnectorContext
  from ray.rllib.evaluation.metrics import RolloutMetrics
  from ray.rllib.examples.env.debug_counter_env import DebugCounterEnv
  from ray.rllib.examples.env.multi_agent import BasicMultiAgent, GuessTheNumberGame
  from ray.rllib.examples.policy.random_policy import RandomPolicy
  from ray.rllib.policy.policy import PolicySpec
  from ray.tune import register_env
  from ray.rllib.policy.sample_batch import convert_ma_batch_to_sample_batch
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec
  from ray.rllib.core.rl_module.marl_module import MultiAgentRLModuleSpec
  from ray.rllib.examples.rl_module.random_rl_module import RandomRLModule
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 5 for calling the TestEnvRunnerV2 obj's underlying member method code with example usage: obj.test_guess_the_number_multi_agent() and returns: unknown, unknown,  list,  dict, unknown,  list,  dict