code: def test_modules(self):
      self.start_tests(name="modules")
  
      with TemporaryDirectory() as directory:
          agent, environment = self.prepare(
              config=dict(
                  device="CPU",
                  eager_mode=False,
                  create_debug_assertions=True,
                  tf_log_level=20,
              )
          )
          states = environment.reset()
          actions = agent.act(states=states)
          states, terminal, reward = environment.execute(
              actions=actions
          )
          agent.observe(terminal=terminal, reward=reward)
          weights0 = agent.model.policy.network.layers[0][
              1
          ].weights.numpy()
          for module in agent.model.tensorforce_submodules:
              path = module.save(directory=directory)
              assert path == os.path.join(
                  directory, module.full_name.replace("/", ".")
              )
          agent.close()
          environment.close()
  
          agent, environment = self.prepare(
              config=dict(
                  device="CPU",
                  eager_mode=False,
                  create_debug_assertions=True,
                  tf_log_level=20,
              )
          )
          states = environment.reset()
          actions = agent.act(states=states)
          states, terminal, reward = environment.execute(
              actions=actions
          )
          agent.observe(terminal=terminal, reward=reward)
          for module in agent.model.tensorforce_submodules:
              module.restore(directory=directory)
          x = agent.model.policy.network.layers[0][1].weights.numpy()
          self.assertTrue(np.allclose(x, weights0))
          actions = agent.act(states=states)
          states, terminal, reward = environment.execute(
              actions=actions
          )
          agent.observe(terminal=terminal, reward=reward)
  
          files = set(os.listdir(path=directory))
          self.assertTrue(
              len(files), 2 * len(agent.model.this_submodules)
          )
          for module in agent.model.tensorforce_submodules:
              filename = module.full_name.replace("/", ".")
              self.assertTrue(filename + ".index" in files)
              self.assertTrue(
                  filename + ".data-00000-of-00001" in files
              )
  
      agent.close()
      environment.close()
  
      self.finished_test()
  
file_path: tensorforce/test/test_saving.py
imports: import os
  from tempfile import TemporaryDirectory
  import unittest
  import numpy
  import tensorflow
  from tensorforce import Agent, Environment, Runner
  from test.unittest_base import UnittestBase
label_desc: Use image node_id 1 for calling the TestSaving obj's underlying member method code with example usage: obj.test_modules() without return types