code: def test_needs_reset(self):
      # MagicMock can mock eval_mode while Mock cannot
      agent = mock.MagicMock()
      env = mock.Mock()
      # First episode: 0 -> 1 -> 2 -> 3 (reset)
      # Second episode: 4 -> 5 -> 6 -> 7 (done)
      env.reset.side_effect = [("state", 0), ("state", 4)]
      env.step.side_effect = [
          (("state", 1), 0, False, {}),
          (("state", 2), 0, False, {}),
          (("state", 3), 0, False, {"needs_reset": True}),
          (("state", 5), -0.5, False, {}),
          (("state", 6), 0, False, {}),
          (("state", 7), 1, True, {}),
      ]
      scores, lengths = evaluator.run_evaluation_episodes(
          env, agent, n_steps=None, n_episodes=2
      )
      assert len(scores) == 2
      assert len(lengths) == 2
  
      np.testing.assert_allclose(scores[0], 0)
      np.testing.assert_allclose(scores[1], 0.5)
      np.testing.assert_allclose(lengths[0], 3)
      np.testing.assert_allclose(lengths[1], 3)
      assert agent.act.call_count == 6
      assert agent.observe.call_count == 6
  
file_path: pfrl/tests/experiments_tests/test_evaluator.py
imports: import tempfile
  import unittest
  from unittest import mock
  import numpy
  import pytest
  import pfrl
  from pfrl.experiments import evaluator
label_desc: Use image node_id 1 for calling the TestRunEvaluationEpisode obj's underlying member method code with example usage: obj.test_needs_reset() without return types