code: def test_save_load_agent(self):
      self.start_tests(name="save-load-agent")
  
      with TemporaryDirectory() as checkpoint_directory, TemporaryDirectory() as numpy_directory:
          # ====================
  
          # OpenAI-Gym environment initialization
          environment = Environment.create(
              environment="benchmarks/configs/cartpole.json"
          )
  
          # PPO agent initialization
          agent = Agent.create(
              agent="benchmarks/configs/ppo.json",
              environment=environment,
              # Option 1: Saver - save agent periodically every 10 updates
              # and keep the 5 most recent checkpoints
              saver=dict(
                  directory=checkpoint_directory,
                  frequency=1,
                  max_checkpoints=5,
              ),
          )
  
          # Runner initialization
          runner = Runner(agent=agent, environment=environment)
  
          # Training
          runner.run(num_episodes=10)
          runner.close()
  
          # Option 2: Explicit save
          # (format: 'numpy' or 'hdf5' store only weights, 'checkpoint' stores full TensorFlow model,
          # agent argument saver, specified above, uses 'checkpoint')
          agent.save(
              directory=numpy_directory,
              format="numpy",
              append="episodes",
          )
  
          # Close agent separately, since created separately
          agent.close()
  
          # Load agent TensorFlow checkpoint
          agent = Agent.load(
              directory=checkpoint_directory,
              format="checkpoint",
              environment=environment,
          )
          runner = Runner(agent=agent, environment=environment)
          runner.run(num_episodes=10, evaluation=True)
          runner.close()
          agent.close()
  
          # Load agent NumPy weights
          agent = Agent.load(
              directory=numpy_directory,
              format="numpy",
              environment=environment,
          )
          runner = Runner(agent=agent, environment=environment)
          runner.run(num_episodes=10, evaluation=True)
          runner.close()
          agent.close()
  
          # Close environment separately, since created separately
          environment.close()
  
      # ====================
  
      self.finished_test()
  
imports: import os
  from tempfile import TemporaryDirectory
  from threading import Thread
  import unittest
  import numpy
  import tensorflow
  from tensorforce import Agent, Environment, Runner
  from test.unittest_base import UnittestBase
label_desc: Use image node_id 10 for calling the TestExamples obj's underlying member method code with example usage: obj.test_save_load_agent() without return types