code: def testRunOneIteration(self, mock_collector_dispatcher):
      mock_collector_dispatcher.return_value = mock.Mock()
      environment_steps = 2
      environment = MockEnvironment(max_steps=environment_steps)
      training_steps = 20
      evaluation_steps = 10
      runner = run_experiment.Runner(
          self._test_subdir,
          self._create_agent_fn,
          lambda: environment,
          training_steps=training_steps,
          evaluation_steps=evaluation_steps,
      )
      dictionary = runner._run_one_iteration(1)
      train_calls = int(training_steps / environment_steps)
      eval_calls = int(evaluation_steps / environment_steps)
      expected_dictionary = {
          "train_episode_lengths": [2 for _ in range(train_calls)],
          "train_episode_returns": [-1 for _ in range(train_calls)],
          "train_average_return": [-1],
          "eval_episode_lengths": [2 for _ in range(eval_calls)],
          "eval_episode_returns": [-1 for _ in range(eval_calls)],
          "eval_average_return": [-1],
      }
      for k in expected_dictionary:
          self.assertEqual(expected_dictionary[k], dictionary[k])
      # Also verify that average number of steps per second is present and
      # positive.
      self.assertLen(dictionary["train_average_steps_per_second"], 1)
      self.assertGreater(
          dictionary["train_average_steps_per_second"][0], 0
      )
      self.assertEqual(1, runner._collector_dispatcher.write.call_count)
      keys = [
          "Train/NumEpisodes",
          "Train/AverageReturns",
          "Train/AverageStepsPerSecond",
          "Eval/NumEpisodes",
          "Eval/AverageReturns",
      ]
      vals = [train_calls, -1.0, None, eval_calls, -1.0]
      arg_pos = 0
      for key, val in zip(keys, vals):
          if val is None:
              arg_pos += 1
              continue  # Ignore steps per second
          self.assertEqual(
              statistics_instance.StatisticsInstance(key, val, 1),
              runner._collector_dispatcher.write.call_args_list[0][0][
                  0
              ][arg_pos],
          )
          arg_pos += 1
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import shutil
  from absl import flags
  from dopamine.agents.dqn import dqn_agent
  from dopamine.agents.implicit_quantile import implicit_quantile_agent
  from dopamine.agents.rainbow import rainbow_agent
  from dopamine.discrete_domains import checkpointer
  from dopamine.discrete_domains import logger
  from dopamine.discrete_domains import run_experiment
  from dopamine.metrics import collector_dispatcher
  from dopamine.metrics import statistics_instance
  import gin.tf
  import mock
  import tensorflow
label_desc: Use image node_id 9 for calling the RunnerTest obj's underlying member method code with example usage: obj.testRunOneIteration(mock_collector_dispatcher) without return types