code: def learn_test_multi_agent_plus_evaluate(algo: str):
      for fw in framework_iterator(frameworks=("tf", "torch")):
          tmp_dir = os.popen("mktemp -d").read()[:-1]
          if not os.path.exists(tmp_dir):
              # Last resort: Resolve via underlying tempdir (and cut tmp_.
              tmp_dir = (
                  ray._private.utils.tempfile.gettempdir() + tmp_dir[4:]
              )
              if not os.path.exists(tmp_dir):
                  sys.exit(1)
  
          print("Saving results to {}".format(tmp_dir))
  
          rllib_dir = str(Path(__file__).parent.parent.absolute())
          print(
              "RLlib dir = {}\nexists={}".format(
                  rllib_dir, os.path.exists(rllib_dir)
              )
          )
  
          def policy_fn(agent_id, episode, **kwargs):
              return "pol{}".format(agent_id)
  
          config = (
              get_trainable_cls(algo)
              .get_default_config()
              .environment(MultiAgentCartPole)
              .framework(fw)
              .rollouts(num_rollout_workers=1)
              .multi_agent(
                  policies={"pol0", "pol1"},
                  policy_mapping_fn=policy_fn,
              )
              .resources(num_gpus=0)
              .evaluation(
                  evaluation_config=AlgorithmConfig.overrides(
                      explore=True
                  )
              )
              .evaluation(
                  evaluation_config=AlgorithmConfig.overrides(
                      explore=True
                  )
              )
              .rl_module(
                  rl_module_spec=MultiAgentRLModuleSpec(
                      module_specs={
                          "pol0": SingleAgentRLModuleSpec(),
                          "pol1": SingleAgentRLModuleSpec(),
                      }
                  ),
              )
          )
  
          stop = {"episode_reward_mean": 100.0}
  
          with mock.patch.dict({"TEST_TMPDIR": tmp_dir}):
              results = tune.Tuner(
                  algo,
                  param_space=config,
                  run_config=air.RunConfig(
                      stop=stop,
                      verbose=1,
                      checkpoint_config=air.CheckpointConfig(
                          checkpoint_frequency=1, checkpoint_at_end=True
                      ),
                      failure_config=air.FailureConfig(
                          fail_fast="raise"
                      ),
                  ),
              ).fit()
  
          # Find last checkpoint and use that for the rollout.
          best_checkpoint = results.get_best_result(
              metric="episode_reward_mean",
              mode="max",
          ).checkpoint
  
          ray.shutdown()
  
          # Test rolling out n steps.
          result = os.popen(
              "python {}/evaluate.py --run={} "
              "--steps=400 "
              '--out="{}/rollouts_n_steps.pkl" "{}"'.format(
                  rllib_dir, algo, tmp_dir, best_checkpoint.path
              )
          ).read()[:-1]
          if not os.path.exists(tmp_dir + "/rollouts_n_steps.pkl"):
              sys.exit(1)
          print("Rollout output exists -> Checking reward ...")
          episodes = result.split("\n")
          mean_reward = 0.0
          num_episodes = 0
          for ep in episodes:
              mo = re.match(r"Episode .+reward: ([\d\.\-]+)", ep)
              if mo:
                  mean_reward += float(mo.group(1))
                  num_episodes += 1
          mean_reward /= num_episodes
          print("Rollout's mean episode reward={}".format(mean_reward))
          assert mean_reward >= 100.0
  
          # Cleanup.
          os.popen('rm -rf "{}"'.format(tmp_dir)).read()
  
imports: import os
  from pathlib import Path
  import re
  import sys
  import unittest
  from unittest import mock
  import ray
  from ray import air, tune
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.examples.env.multi_agent import MultiAgentCartPole
  from ray.rllib.utils.test_utils import framework_iterator
  from ray.tune.registry import get_trainable_cls
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec
  from ray.rllib.core.rl_module.marl_module import MultiAgentRLModuleSpec
label_desc: Use image node_id 3 for calling a global function with example usage: learn_test_multi_agent_plus_evaluate(algo) and returns: str