code: def visualize(
      logdir, outdir, num_agents, num_episodes, checkpoint=None,
      env_processes=True):
    
    config = utility.load_config(logdir)
    with tf.device('/cpu:0'):
      batch_env = utility.define_batch_env(
          lambda: _create_environment(config, outdir),
          num_agents, env_processes)
      graph = utility.define_simulation_graph(
          batch_env, config.algorithm, config)
      total_steps = num_episodes * config.max_length
      loop = _define_loop(graph, total_steps)
    saver = utility.define_saver(
        exclude=(r'.*_temporary.*', r'global_step'))
    sess_config = tf.ConfigProto(allow_soft_placement=True)
    sess_config.gpu_options.allow_growth = True
    with tf.Session(config=sess_config) as sess:
      utility.initialize_variables(
          sess, saver, config.logdir, checkpoint, resume=True)
      for unused_score in loop.run(sess, saver, total_steps):
        pass
    batch_env.close()
docs: Recover checkpoint and render videos from it.
  
    Args:
      logdir: Logging directory of the trained algorithm.
      outdir: Directory to store rendered videos in.
      num_agents: Number of environments to simulate in parallel.
      num_episodes: Total number of episodes to simulate.
      checkpoint: Checkpoint name to load; defaults to most recent.
      env_processes: Whether to step environments in separate processes.