code: def recursively_scan(discounts, cs, deltas):
      r"""Recursively calculate vs_minus_v_xs according to following equation:
      vs_minus_v_xs(t) = deltas(t) + discounts(t) * cs(t) * vs_minus_v_xs(t + 1)
  
      Args:
          discounts: A float32 tensor of shape [T, B] with discounts encountered when
                     following the behaviour policy.
          cs: A float32 tensor of shape [T, B], which corresponding to $c_s$ in the
              origin paper.
          deltas: A float32 tensor of shape [T, B], which corresponding to
                  $\delta_s * V$ in the origin paper.
  
      Returns:
          vs_minus_v_xs: A float32 tensor of shape [T, B], which corresponding to
                         $v_s - V(x_s)$ in the origin paper.
      """
  
      # All sequences are reversed, computation starts from the back.
      reverse_discounts = layers.reverse(x=discounts, axis=[0])
      reverse_cs = layers.reverse(x=cs, axis=[0])
      reverse_deltas = layers.reverse(x=deltas, axis=[0])
  
      static_while = layers.StaticRNN()
      # init: shape [B]
      init = layers.fill_constant_batch_size_like(
          discounts,
          shape=[1],
          dtype="float32",
          value=0.0,
          input_dim_idx=1,
      )
  
      with static_while.step():
          discount_t = static_while.step_input(reverse_discounts)
          c_t = static_while.step_input(reverse_cs)
          delta_t = static_while.step_input(reverse_deltas)
  
          vs_minus_v_xs_t_plus_1 = static_while.memory(init=init)
          vs_minus_v_xs_t = (
              delta_t + discount_t * c_t * vs_minus_v_xs_t_plus_1
          )
  
          static_while.update_memory(
              vs_minus_v_xs_t_plus_1, vs_minus_v_xs_t
          )
  
          static_while.step_output(vs_minus_v_xs_t)
  
      vs_minus_v_xs = static_while()
  
      # Reverse the results back to original order.
      vs_minus_v_xs = layers.reverse(vs_minus_v_xs, [0])
  
      return vs_minus_v_xs
  
imports: import collections
  import paddle.fluid
  from parl.core.fluid import layers
  from parl.utils import MAX_INT32
label_desc: Use image node_id 2 for calling a global function with example usage: recursively_scan(discounts, cs, deltas) and returns: vs_minus_v_xs