code: def retrace(
      q_tm1: Array,
      q_t: Array,
      a_tm1: Array,
      a_t: Array,
      r_t: Array,
      discount_t: Array,
      pi_t: Array,
      mu_t: Array,
      lambda_: float,
      eps: float = 1e-8,
      stop_target_gradients: bool = True,
  ) -> Array:
      """Calculates Retrace errors.
  
      See "Safe and Efficient Off-Policy Reinforcement Learning" by Munos et al.
      (https://arxiv.org/abs/1606.02647).
  
      Args:
        q_tm1: Q-values at time t-1.
        q_t: Q-values at time t.
        a_tm1: action index at time t-1.
        a_t: action index at time t.
        r_t: reward at time t.
        discount_t: discount at time t.
        pi_t: target policy probs at time t.
        mu_t: behavior policy probs at time t.
        lambda_: scalar mixing parameter lambda.
        eps: small value to add to mu_t for numerical stability.
        stop_target_gradients: bool indicating whether or not to apply stop gradient
          to targets.
  
      Returns:
        Retrace error.
      """
      chex.assert_rank(
          [q_tm1, q_t, a_tm1, a_t, r_t, discount_t, pi_t, mu_t],
          [2, 2, 1, 1, 1, 1, 2, 1],
      )
      chex.assert_type(
          [q_tm1, q_t, a_tm1, a_t, r_t, discount_t, pi_t, mu_t],
          [float, float, int, int, float, float, float, float],
      )
  
      pi_a_t = base.batched_index(pi_t, a_t)
      c_t = jnp.minimum(1.0, pi_a_t / (mu_t + eps)) * lambda_
      target_tm1 = (
          multistep.general_off_policy_returns_from_action_values(
              q_t, a_t, r_t, discount_t, c_t, pi_t
          )
      )
  
      q_a_tm1 = base.batched_index(q_tm1, a_tm1)
  
      target_tm1 = jax.lax.select(
          stop_target_gradients,
          jax.lax.stop_gradient(target_tm1),
          target_tm1,
      )
      return target_tm1 - q_a_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 12 for calling a global function with example usage: retrace(q_tm1, q_t, a_tm1, a_t, r_t, discount_t, pi_t, mu_t, lambda_, eps, stop_target_gradients) and returns: unknown