code: def test(self):
      outdir = tempfile.mkdtemp()
  
      agent = mock.Mock()
      env = mock.Mock()
      # Reaches the terminal state after five actions
      env.reset.side_effect = [("state", 0)]
      env.step.side_effect = [
          (("state", 1), 0, False, {}),
          (("state", 2), 0, False, {}),
          (("state", 3), -0.5, False, {}),
          (("state", 4), 0, False, {}),
          (("state", 5), 1, True, {}),
      ]
      hook = mock.Mock()
  
      chainerrl.experiments.train_agent(
          agent=agent,
          env=env,
          steps=5,
          outdir=outdir,
          step_hooks=[hook],
      )
  
      self.assertEqual(agent.act_and_train.call_count, 5)
      self.assertEqual(agent.stop_episode_and_train.call_count, 1)
  
      self.assertEqual(env.reset.call_count, 1)
      self.assertEqual(env.step.call_count, 5)
  
      self.assertEqual(hook.call_count, 5)
      # A hook receives (env, agent, step)
      for i, call in enumerate(hook.call_args_list):
          args, kwargs = call
          self.assertEqual(args[0], env)
          self.assertEqual(args[1], agent)
          # step starts with 1
          self.assertEqual(args[2], i + 1)
  
file_path: chainerrl/tests/experiments_tests/test_train_agent.py
imports: import tempfile
  import unittest
  from unittest import mock
  import chainerrl
label_desc: Use image node_id 1 for calling the TestTrainAgent obj's underlying member method code with example usage: obj.test() without return types