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: Returns a function with the condition needed for tf.while_loop.
docstr_tok: ["Returns","a","function","with","the","condition","needed","for","tf.while_loop","."]
code: def _loop_condition_fn(self, num_episodes):
      """Returns a function with the condition needed for tf.while_loop."""
  
      def loop_cond(counter, *_):
          """Determines when to stop the loop, based on episode counter.
  
          Args:
            counter: Episode counters per batch index. Shape [batch_size] when
              batch_size > 1, else shape [].
  
          Returns:
            tf.bool tensor, shape (), indicating whether while loop should continue.
          """
          return tf.less(
              tf.reduce_sum(input_tensor=counter), num_episodes
          )
  
      return loop_cond
  
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 2 for calling the DynamicEpisodeDriver obj's underlying member method code with example usage: obj._loop_condition_fn(num_episodes) and returns: loop_cond, tf