code: def td_lambda(
      v_tm1: Array,
      r_t: Array,
      discount_t: Array,
      v_t: Array,
      lambda_: Numeric,
      stop_target_gradients: bool = True,
  ) -> Array:
      """Calculates the TD(lambda) temporal difference error.
  
      See "Reinforcement Learning: An Introduction" by Sutton and Barto.
      (http://incompleteideas.net/book/ebook/node74.html).
  
      Args:
        v_tm1: sequence of state values at time t-1.
        r_t: sequence of rewards at time t.
        discount_t: sequence of discounts at time t.
        v_t: sequence of state values at time t.
        lambda_: mixing parameter lambda, either a scalar or a sequence.
        stop_target_gradients: bool indicating whether or not to apply stop gradient
          to targets.
      Returns:
        TD(lambda) temporal difference error.
      """
      chex.assert_rank(
          [v_tm1, r_t, discount_t, v_t, lambda_], [1, 1, 1, 1, {0, 1}]
      )
      chex.assert_type([v_tm1, r_t, discount_t, v_t, lambda_], float)
  
      target_tm1 = multistep.lambda_returns(
          r_t, discount_t, v_t, lambda_
      )
      target_tm1 = jax.lax.select(
          stop_target_gradients,
          jax.lax.stop_gradient(target_tm1),
          target_tm1,
      )
      return target_tm1 - v_tm1
  
imports: from typing import Union
  import chex
  import jax
  import jax.numpy
  from rlax._src import base
  from rlax._src import clipping
  from rlax._src import distributions
  from rlax._src import multistep
label_desc: Use image node_id 2 for calling a global function with example usage: td_lambda(v_tm1, r_t, discount_t, v_t, lambda_, stop_target_gradients) and returns: unknown