class_docstr: Runner class to run Tandem RL experiments.
class_docstr_tok: ["Runner","class","to","run","Tandem","RL","experiments","."]
docstr: Runs the agent/environment loop until a desired number of steps.
  
  We follow the Machado et al., 2017 convention of running full episodes,
  and terminating once we've run a minimum number of steps.
  
  Args:
    min_steps: int, minimum number of steps to generate in this phase.
    statistics: `IterationStatistics` object which records the experimental
      results.
    run_mode_str: str, describes the run mode for this agent.
    agent_type: str, the type of agent to run.
  
  Returns:
    Tuple containing the number of steps taken in this phase (int), the sum of
      returns (float), and the number of episodes performed (int).
docstr_tok: ["Runs","the","agent\/environment","loop","until","a","desired","number","of","steps",".","We","follow","the","Machado","et","al.",",","2017","convention","of","running","full","episodes",",","and","terminating","once","we","'ve","run","a","minimum","number","of","steps",".","Args",":","min_steps",":","int",",","minimum","number","of","steps","to","generate","in","this","phase",".","statistics",":","`","IterationStatistics","`","object","which","records","the","experimental","results",".","run_mode_str",":","str",",","describes","the","run","mode","for","this","agent",".","agent_type",":","str",",","the","type","of","agent","to","run",".","Returns",":","Tuple","containing","the","number","of","steps","taken","in","this","phase","(","int",")",",","the","sum","of","returns","(","float",")",",","and","the","number","of","episodes","performed","(","int",")","."]
code: def _run_one_phase(
      self, min_steps, statistics, run_mode_str, agent_type="active"
  ):
      """Runs the agent/environment loop until a desired number of steps.
  
      We follow the Machado et al., 2017 convention of running full episodes,
      and terminating once we've run a minimum number of steps.
  
      Args:
        min_steps: int, minimum number of steps to generate in this phase.
        statistics: `IterationStatistics` object which records the experimental
          results.
        run_mode_str: str, describes the run mode for this agent.
        agent_type: str, the type of agent to run.
  
      Returns:
        Tuple containing the number of steps taken in this phase (int), the sum of
          returns (float), and the number of episodes performed (int).
      """
      step_count = 0
      num_episodes = 0
      sum_returns = 0.0
  
      while step_count < min_steps:
          episode_length, episode_return = self._run_one_episode(
              agent_type
          )
          statistics.append(
              {
                  "{}_{}_episode_lengths".format(
                      run_mode_str, agent_type
                  ): episode_length,
                  "{}_{}_episode_returns".format(
                      run_mode_str, agent_type
                  ): episode_return,
              }
          )
          step_count += episode_length
          sum_returns += episode_return
          num_episodes += 1
          # We use sys.stdout.write instead of logging so as to flush frequently
          # without generating a line break.
          sys.stdout.write(
              "Steps executed: {} ".format(step_count)
              + "Episode length: {} ".format(episode_length)
              + "Return: {}\r".format(episode_return)
          )
          sys.stdout.flush()
      return step_count, sum_returns, num_episodes
  
imports: import sys
  from absl import logging
  from dopamine.discrete_domains import atari_lib
  from dopamine.discrete_domains import gym_lib
  from dopamine.discrete_domains import iteration_statistics
  from dopamine.discrete_domains import run_experiment
  from dopamine.labs.environments.minatar import minatar_env
  from dopamine.labs.tandem_dqn import tandem_dqn_agent
  import gin
  import numpy
  import tensorflow
label_desc: Use image node_id 4 for calling the TandemRunner obj's underlying member method code with example usage: obj._run_one_phase(min_steps, statistics, run_mode_str, agent_type) and returns: step_count,  sum_returns,  num_episodes