class_docstr: Implements a Piecewise Scheduler.
class_docstr_tok: ["Implements","a","Piecewise","Scheduler","."]
code: def _tf_value_op(self, t: TensorType) -> TensorType:
      assert self.outside_value is not None, (
          "tf-version of PiecewiseSchedule requires `outside_value` to be "
          "provided!"
      )
  
      endpoints = tf.cast(
          tf.stack([e[0] for e in self.endpoints] + [-1]), tf.int64
      )
  
      # Create all possible interpolation results.
      results_list = []
      for (l_t, l), (r_t, r) in zip(
          self.endpoints[:-1], self.endpoints[1:]
      ):
          alpha = tf.cast(t - l_t, tf.float32) / tf.cast(
              r_t - l_t, tf.float32
          )
          results_list.append(self.interpolation(l, r, alpha))
      # If t does not belong to any of the pieces, return `outside_value`.
      results_list.append(self.outside_value)
      results_list = tf.stack(results_list)
  
      # Return correct results tensor depending on where we find t.
      def _cond(i, x):
          x = tf.cast(x, tf.int64)
          return tf.logical_not(
              tf.logical_or(
                  tf.equal(endpoints[i + 1], -1),
                  tf.logical_and(
                      endpoints[i] <= x, x < endpoints[i + 1]
                  ),
              )
          )
  
      def _body(i, x):
          return (i + 1, t)
  
      idx_and_t = tf.while_loop(
          _cond, _body, [tf.constant(0, dtype=tf.int64), t]
      )
      return results_list[idx_and_t[0]]
  
file_path: ray/python/ray/rllib/utils/schedules/piecewise_schedule.py
imports: from typing import Callable, List, Optional, Tuple
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.schedules.schedule import Schedule
  from ray.rllib.utils.typing import TensorType
label_desc: Use image node_id 3 for calling the PiecewiseSchedule obj's underlying member method code with example usage: obj._tf_value_op(t) and returns: results_list, tf, unknown,  t