docstr: Check error cases for load_module_state.
  
  check that loading marl modules and specifing a module id to
  be loaded using modules_to_load and rl_module_ckpt_dirs raises
  an error
docstr_tok: ["Check","error","cases","for","load_module_state",".","check","that","loading","marl","modules","and","specifing","a","module","id","to","be","loaded","using","modules_to_load","and","rl_module_ckpt_dirs","raises","an","error"]
code: def test_load_module_state_errors(self):
      """Check error cases for load_module_state.
  
      check that loading marl modules and specifing a module id to
      be loaded using modules_to_load and rl_module_ckpt_dirs raises
      an error
      """
      # env will have agent ids 0 and 1
      env = MultiAgentCartPole({"num_agents": 2})
  
      config_overrides = LOCAL_CONFIGS["local-cpu"]
      config = BaseTestingAlgorithmConfig().update_from_dict(
          config_overrides
      )
      learner_group = config.build_learner_group(env=env)
      rl_module_spec = config.get_default_rl_module_spec()
      rl_module_spec.observation_space = env.observation_space
      rl_module_spec.action_space = env.action_space
  
      learner_group.add_module(
          module_id="0", module_spec=rl_module_spec
      )
      learner_group.add_module(
          module_id="1", module_spec=rl_module_spec
      )
      learner_group.remove_module(DEFAULT_POLICY_ID)
  
      module_0 = rl_module_spec.build()
      module_1 = rl_module_spec.build()
      marl_module = MultiAgentRLModule()
      marl_module.add_module(module_id="0", module=module_0)
      marl_module.add_module(module_id="1", module=module_1)
  
      with tempfile.TemporaryDirectory() as tmpdir:
          module_0.save_to_checkpoint(tmpdir)
          with tempfile.TemporaryDirectory() as tmpdir:
              module_0 = rl_module_spec.build()
              marl_module = MultiAgentRLModule()
              marl_module.add_module(module_id="0", module=module_0)
              marl_module.add_module(
                  module_id="1", module=rl_module_spec.build()
              )
              marl_module.save_to_checkpoint(tmpdir)
              with tempfile.TemporaryDirectory() as tmpdir2:
                  module_1 = rl_module_spec.build()
                  module_1.save_to_checkpoint(tmpdir2)
                  with self.assertRaisesRegex(
                      (ValueError,),
                      ".*`modules_to_load` AND `rl_module_ckpt_dirs`!.*",
                  ):
                      # check that loading marl modules and specifing a module id to
                      # be loaded using modules_to_load and rl_module_ckpt_dirs raises
                      # an error
                      learner_group.load_module_state(
                          marl_module_ckpt_dir=tmpdir,
                          rl_module_ckpt_dirs={"1": tmpdir2},
                          modules_to_load={
                              "1",
                          },
                      )
          del learner_group
  
imports: import gymnasium
  import itertools
  import numpy
  from typing import Any, Dict, List
  import tempfile
  import unittest
  import ray
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.ppo.tests.test_ppo_learner import FAKE_BATCH
  from ray.rllib.core.learner.learner import Learner
  from ray.rllib.core.rl_module.marl_module import MultiAgentRLModule
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec
  from ray.rllib.core.testing.tf.bc_learner import BCTfLearner
  from ray.rllib.core.testing.tf.bc_module import DiscreteBCTFModule
  from ray.rllib.core.testing.utils import add_module_to_learner_or_learner_group
  from ray.rllib.core.testing.testing_learner import BaseTestingAlgorithmConfig
  from ray.rllib.examples.env.multi_agent import MultiAgentCartPole
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID, SampleBatch, MultiAgentBatch
  from ray.rllib.utils.test_utils import check, get_cartpole_dataset_reader
  from ray.rllib.utils.metrics import ALL_MODULES
  from ray.util.timer import _Timer
label_desc: Use image node_id 4 for calling the TestLearnerGroupCheckpointRestore obj's underlying member method code with example usage: obj.test_load_module_state_errors() without return types