code: def q_lambda(
      q_tm1: Array,
      a_tm1: Array,
      r_t: Array,
      discount_t: Array,
      q_t: Array,
      lambda_: Numeric,
      stop_target_gradients: bool = True,
  ) -> Array:
      """Calculates Peng's or Watkins' Q(lambda) temporal difference error.
  
      See "Reinforcement Learning: An Introduction" by Sutton and Barto.
      (http://incompleteideas.net/book/ebook/node78.html).
  
      Args:
        q_tm1: sequence of Q-values at time t-1.
        a_tm1: sequence of action indices at time t-1.
        r_t: sequence of rewards at time t.
        discount_t: sequence of discounts at time t.
        q_t: sequence of Q-values at time t.
        lambda_: mixing parameter lambda, either a scalar (e.g. Peng's Q(lambda)) or
          a sequence (e.g. Watkin's Q(lambda)).
        stop_target_gradients: bool indicating whether or not to apply stop gradient
          to targets.
  
      Returns:
        Q(lambda) temporal difference error.
      """
      chex.assert_rank(
          [q_tm1, a_tm1, r_t, discount_t, q_t, lambda_],
          [2, 1, 1, 1, 2, {0, 1}],
      )
      chex.assert_type(
          [q_tm1, a_tm1, r_t, discount_t, q_t, lambda_],
          [float, int, float, float, float, float],
      )
  
      qa_tm1 = base.batched_index(q_tm1, a_tm1)
      v_t = jnp.max(q_t, axis=-1)
      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 - qa_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 11 for calling a global function with example usage: q_lambda(q_tm1, a_tm1, r_t, discount_t, q_t, lambda_, stop_target_gradients) and returns: unknown