class_docstr: Train and evaluate DQN on Atari.
class_docstr_tok: ["Train","and","evaluate","DQN","on","Atari","."]
docstr: Collect initial experience before training begins.
docstr_tok: ["Collect","initial","experience","before","training","begins","."]
code: def _initial_collect(self):
      """Collect initial experience before training begins."""
      logging.info("Collecting initial experience...")
      time_step_spec = ts.time_step_spec(self._env.observation_spec())
      random_policy = random_py_policy.RandomPyPolicy(
          time_step_spec, self._env.action_spec()
      )
      time_step = self._env.reset()
      while self._replay_buffer.size < self._initial_collect_steps:
          if self.game_over():
              time_step = self._env.reset()
          action_step = random_policy.action(time_step)
          next_time_step = self._env.step(action_step.action)
          self._replay_buffer.add_batch(
              trajectory.from_transition(
                  time_step, action_step, next_time_step
              )
          )
          time_step = next_time_step
      logging.info("Done.")
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl import app
  from absl import flags
  from absl import logging
  import gin
  import numpy
  import tensorflow
  from tf_agents.agents.categorical_dqn import categorical_dqn_agent
  from tf_agents.environments import batched_py_environment
  from tf_agents.environments import suite_atari
  from tf_agents.eval import metric_utils
  from tf_agents.metrics import py_metric
  from tf_agents.metrics import py_metrics
  from tf_agents.networks import categorical_q_network
  from tf_agents.networks import network
  from tf_agents.policies import epsilon_greedy_policy
  from tf_agents.policies import py_tf_policy
  from tf_agents.policies import random_py_policy
  from tf_agents.replay_buffers import py_hashed_replay_buffer
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import common
  from tf_agents.utils import timer
label_desc: Use image node_id 5 for calling the TrainEval obj's underlying member method code with example usage: obj._initial_collect() without return types