class_docstr: A driver that takes N episodes in an environment using a tf.while_loop.
  
  The while loop will run num_episodes in the environment, counting transitions
  that result in ending an episode.
  
  As environments run batched time_episodes, the counters for all batch elements
  are summed, and execution stops when the total exceeds num_episodes.
  
  This termination condition can be overridden in subclasses by implementing the
  self._loop_condition_fn() method.
class_docstr_tok: ["A","driver","that","takes","N","episodes","in","an","environment","using","a","tf.while_loop",".","The","while","loop","will","run","num_episodes","in","the","environment",",","counting","transitions","that","result","in","ending","an","episode",".","As","environments","run","batched","time_episodes",",","the","counters","for","all","batch","elements","are","summed",",","and","execution","stops","when","the","total","exceeds","num_episodes",".","This","termination","condition","can","be","overridden","in","subclasses","by","implementing","the","self._loop_condition_fn","(",")","method","."]
docstr: See `run()` docstring for details.
docstr_tok: ["See","`","run","(",")","`","docstring","for","details","."]
code: def _run(
      self,
      time_step=None,
      policy_state=None,
      num_episodes=None,
      maximum_iterations=None,
  ):
      """See `run()` docstring for details."""
      if time_step is None:
          time_step = self.env.reset()
  
      if policy_state is None:
          policy_state = self.policy.get_initial_state(
              self.env.batch_size
          )
  
      # Batch dim should be first index of tensors during data
      # collection.
      batch_dims = nest_utils.get_outer_shape(
          time_step, self.env.time_step_spec()
      )
      counter = tf.zeros(batch_dims, tf.int32)
  
      num_episodes = num_episodes or self._num_episodes
      [_, time_step, policy_state] = tf.nest.map_structure(
          tf.stop_gradient,
          tf.while_loop(
              cond=self._loop_condition_fn(num_episodes),
              body=self._loop_body_fn(),
              loop_vars=[counter, time_step, policy_state],
              parallel_iterations=1,
              maximum_iterations=maximum_iterations,
              name="driver_loop",
          ),
      )
  
      return time_step, policy_state
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gin
  import tensorflow
  from tf_agents.bandits.environments import bandit_py_environment
  from tf_agents.bandits.environments import bandit_tf_environment
  from tf_agents.drivers import driver
  from tf_agents.environments import tf_py_environment
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 5 for calling the DynamicEpisodeDriver obj's underlying member method code with example usage: obj._run(time_step, policy_state, num_episodes, maximum_iterations) and returns: time_step,  policy_state