code: def test_save_and_restore(self):
      for algo_name in algorithms_and_configs:
          config = algorithms_and_configs[algo_name]
          for _ in framework_iterator(
              config, frameworks=["torch", "tf2"]
          ):
              with tempfile.TemporaryDirectory() as tmpdir:
                  # create an algorithm, checkpoint it, then train for 2 iterations
                  ray.get(
                      save_and_train.remote(
                          config, "CartPole-v1", tmpdir
                      )
                  )
                  # load that checkpoint into a new algorithm and train for 2
                  # iterations
                  results_algo_2 = ray.get(
                      load_and_train.remote(
                          config, "CartPole-v1", tmpdir
                      )
                  )
  
                  # load that checkpoint into another new algorithm and train for 2
                  # iterations
                  results_algo_3 = ray.get(
                      load_and_train.remote(
                          config, "CartPole-v1", tmpdir
                      )
                  )
  
                  # check that the results are the same across loaded algorithms
                  # they won't be the same as the first algorithm since the random
                  # state that is used for each algorithm is not preserved across
                  # checkpoints.
                  check(results_algo_3, results_algo_2)
  
file_path: ray/rllib/tests/test_algorithm_save_load_checkpoint_learner.py
imports: import tempfile
  import unittest
  import ray
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.utils.test_utils import check, framework_iterator
  from ray.rllib.algorithms.ppo import PPOConfig
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.metrics.learner_info import LEARNER_INFO
label_desc: Use image node_id 3 for calling the TestAlgorithmWithLearnerSaveAndRestore obj's underlying member method code with example usage: obj.test_save_and_restore() without return types