class_docstr: Runner for evaluating using a fixed number of episodes rather than steps.
  
  Also restricts data collection to a strict cap,
  following conventions in data-efficient RL research.
class_docstr_tok: ["Runner","for","evaluating","using","a","fixed","number","of","episodes","rather","than","steps",".","Also","restricts","data","collection","to","a","strict","cap",",","following","conventions","in","data-efficient","RL","research","."]
docstr: Run training phase.
  
  Args:
    statistics: `IterationStatistics` object which records the experimental
      results. Note - This object is modified by this method.
  
  Returns:
    num_episodes: int, The number of episodes run in this phase.
    average_reward: float, The average reward generated in this phase.
    average_steps_per_second: float, The average number of steps per
    second.
docstr_tok: ["Run","training","phase",".","Args",":","statistics",":","`","IterationStatistics","`","object","which","records","the","experimental","results",".","Note","-","This","object","is","modified","by","this","method",".","Returns",":","num_episodes",":","int",",","The","number","of","episodes","run","in","this","phase",".","average_reward",":","float",",","The","average","reward","generated","in","this","phase",".","average_steps_per_second",":","float",",","The","average","number","of","steps","per","second","."]
code: def _run_train_phase(self, statistics):
      """Run training phase.
  
      Args:
        statistics: `IterationStatistics` object which records the experimental
          results. Note - This object is modified by this method.
  
      Returns:
        num_episodes: int, The number of episodes run in this phase.
        average_reward: float, The average reward generated in this phase.
        average_steps_per_second: float, The average number of steps per
        second.
      """
      # Perform the training phase, during which the agent learns.
      self._agent.eval_mode = False
      self._agent.restore_train_state()
      start_time = time.time()
      (
          number_steps,
          sum_returns,
          num_episodes,
          self.train_state,
          self.train_envs,
      ) = self._run_one_phase(
          self.train_envs,
          self._training_steps,
          max_episodes=None,
          statistics=statistics,
          run_mode_str="train",
          needs_reset=self.train_state is None,
          resume_state=self.train_state,
      )
      average_return = (
          sum_returns / num_episodes if num_episodes > 0 else 0.0
      )
      statistics.append({"train_average_return": average_return})
      time_delta = time.time() - start_time
      average_steps_per_second = number_steps / time_delta
      statistics.append(
          {"train_average_steps_per_second": average_steps_per_second}
      )
      logging.info(
          "Average undiscounted return per training episode: %.2f",
          average_return,
      )
      logging.info(
          "Average training steps per second: %.2f",
          average_steps_per_second,
      )
  
      if self.log_normalized_scores:
          normalized_return = normalization_utils.normalize_score(
              average_return, self.game_name
          )
          statistics.append(
              {"train_average_normalized_score": normalized_return}
          )
          logging.info(
              "Average normalized return per training episode: %.2f",
              normalized_return,
          )
      else:
          normalized_return = None
  
      self._agent.cache_train_state()
      return (
          num_episodes,
          average_return,
          average_steps_per_second,
          normalized_return,
      )
  
imports: import functools
  import os
  import sys
  import time
  from absl import logging
  from dopamine.discrete_domains import atari_lib
  from dopamine.discrete_domains import iteration_statistics
  from dopamine.discrete_domains import run_experiment
  from dopamine.labs.atari_100k import normalization_utils
  from dopamine.metrics import collector_dispatcher
  from dopamine.metrics import statistics_instance
  import gin
  import jax
  import numpy
  import tensorflow
label_desc: Use image node_id 5 for calling the DataEfficientAtariRunner obj's underlying member method code with example usage: obj._run_train_phase(statistics) and returns: num_episodes,  average_return,  average_steps_per_second,  normalized_return