docstr: Tests, whether per-module config overrides (multi-agent) work as expected.
docstr_tok: ["Tests",",","whether","per-module","config","overrides","(","multi-agent",")","work","as","expected","."]
code: def test_config_per_module(self):
      """Tests, whether per-module config overrides (multi-agent) work as expected."""
  
      # Compile individual agents' PPO configs from a config object.
      config = (
          PPOConfig()
          .training(kl_coeff=0.5)
          .multi_agent(
              policies={"module_1", "module_2", "module_3"},
              # Override config settings fro `module_1` and `module_2`.
              algorithm_config_overrides_per_module={
                  "module_1": PPOConfig.overrides(
                      lr=0.01, kl_coeff=0.1
                  ),
                  "module_2": PPOConfig.overrides(grad_clip=100.0),
              },
          )
      )
  
      # Check default config.
      check(config.lr, 0.00005)
      check(config.grad_clip, None)
      check(config.grad_clip_by, "global_norm")
      check(config.kl_coeff, 0.5)
  
      # `module_1` overrides.
      config_1 = config.get_config_for_module("module_1")
      check(config_1.lr, 0.01)
      check(config_1.grad_clip, None)
      check(config_1.grad_clip_by, "global_norm")
      check(config_1.kl_coeff, 0.1)
  
      # `module_2` overrides.
      config_2 = config.get_config_for_module("module_2")
      check(config_2.lr, 0.00005)
      check(config_2.grad_clip, 100.0)
      check(config_2.grad_clip_by, "global_norm")
      check(config_2.kl_coeff, 0.5)
  
      # No `module_3` overrides (b/c module_3 uses the top-level config
      # object directly).
      self.assertTrue("module_3" not in config._per_module_overrides)
      config_3 = config.get_config_for_module("module_3")
      self.assertTrue(config_3 is config)
  
imports: import gymnasium
  from typing import Type
  import unittest
  import ray
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.callbacks import make_multi_callbacks
  from ray.rllib.algorithms.ppo import PPO, PPOConfig
  from ray.rllib.algorithms.ppo.tf.ppo_tf_learner import PPOTfLearner
  from ray.rllib.algorithms.ppo.torch.ppo_torch_rl_module import PPOTorchRLModule
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec, RLModule
  from ray.rllib.core.rl_module.marl_module import MultiAgentRLModuleSpec, MultiAgentRLModule
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 9 for calling the TestAlgorithmConfig obj's underlying member method code with example usage: obj.test_config_per_module() without return types