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: Creates a DynamicEpisodeDriver.
  
  **Note** about bias when using batched environments with `num_episodes`:
  When using `num_episodes != None`, a `run` step "finishes" when
  `num_episodes` have been completely collected (hit a boundary).
  When used in conjunction with environments that have variable-length
  episodes, this skews the distribution of collected episodes' lengths:
  short episodes are seen more frequently than long ones.
  As a result, running an `env` of `N > 1` batched environments
  with `num_episodes >= 1` is not the same as running an env with `1`
  environment with `num_episodes >= 1`.
  
  Args:
    env: A tf_environment.Base environment.
    policy: A tf_policy.TFPolicy policy.
    observers: A list of observers that are updated after every step in the
      environment. Each observer is a callable(Trajectory).
    transition_observers: A list of observers that are updated after every
      step in the environment. Each observer is a callable((TimeStep,
      PolicyStep, NextTimeStep)).
    num_episodes: The number of episodes to take in the environment. For
      batched or parallel environments, this is the total number of episodes
      summed across all environments.
  
  Raises:
    ValueError:
      If env is not a tf_environment.Base or policy is not an instance of
      tf_policy.TFPolicy.
docstr_tok: ["Creates","a","DynamicEpisodeDriver",".","*","*","Note","*","*","about","bias","when","using","batched","environments","with","`","num_episodes","`",":","When","using","`","num_episodes","!","=","None","`",",","a","`","run","`","step","``","finishes","''","when","`","num_episodes","`","have","been","completely","collected","(","hit","a","boundary",")",".","When","used","in","conjunction","with","environments","that","have","variable-length","episodes",",","this","skews","the","distribution","of","collected","episodes","'","lengths",":","short","episodes","are","seen","more","frequently","than","long","ones",".","As","a","result",",","running","an","`","env","`","of","`","N",">","1","`","batched","environments","with","`","num_episodes",">","=","1","`","is","not","the","same","as","running","an","env","with","`","1","`","environment","with","`","num_episodes",">","=","1","`",".","Args",":","env",":","A","tf_environment.Base","environment",".","policy",":","A","tf_policy.TFPolicy","policy",".","observers",":","A","list","of","observers","that","are","updated","after","every","step","in","the","environment",".","Each","observer","is","a","callable","(","Trajectory",")",".","transition_observers",":","A","list","of","observers","that","are","updated","after","every","step","in","the","environment",".","Each","observer","is","a","callable","(","(","TimeStep",",","PolicyStep",",","NextTimeStep",")",")",".","num_episodes",":","The","number","of","episodes","to","take","in","the","environment",".","For","batched","or","parallel","environments",",","this","is","the","total","number","of","episodes","summed","across","all","environments",".","Raises",":","ValueError",":","If","env","is","not","a","tf_environment.Base","or","policy","is","not","an","instance","of","tf_policy.TFPolicy","."]
code: def __init__(
      self,
      env,
      policy,
      observers=None,
      transition_observers=None,
      num_episodes=1,
  ):
      """Creates a DynamicEpisodeDriver.
  
      **Note** about bias when using batched environments with `num_episodes`:
      When using `num_episodes != None`, a `run` step "finishes" when
      `num_episodes` have been completely collected (hit a boundary).
      When used in conjunction with environments that have variable-length
      episodes, this skews the distribution of collected episodes' lengths:
      short episodes are seen more frequently than long ones.
      As a result, running an `env` of `N > 1` batched environments
      with `num_episodes >= 1` is not the same as running an env with `1`
      environment with `num_episodes >= 1`.
  
      Args:
        env: A tf_environment.Base environment.
        policy: A tf_policy.TFPolicy policy.
        observers: A list of observers that are updated after every step in the
          environment. Each observer is a callable(Trajectory).
        transition_observers: A list of observers that are updated after every
          step in the environment. Each observer is a callable((TimeStep,
          PolicyStep, NextTimeStep)).
        num_episodes: The number of episodes to take in the environment. For
          batched or parallel environments, this is the total number of episodes
          summed across all environments.
  
      Raises:
        ValueError:
          If env is not a tf_environment.Base or policy is not an instance of
          tf_policy.TFPolicy.
      """
      super(DynamicEpisodeDriver, self).__init__(
          env, policy, observers, transition_observers
      )
      self._num_episodes = num_episodes
      self._run_fn = common.function_in_tf1()(self._run)
      self._is_bandit_env = is_bandit_env(env)
  
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 1 to create a new DynamicEpisodeDriver object from inherited base classes: driver with example: obj = DynamicEpisodeDriver(env, policy, observers, transition_observers, num_episodes)