code: def compute_parametric_kl_penalty_and_dual_loss(
      kl_constraints: Sequence[Tuple[Array, LagrangePenalty]],
      projection_operator: ProjectionOperatorFn,
      use_stop_gradient: bool = True,
  ) -> Tuple[Array, Array]:
      """Optimize hard KL constraints between the current and previous policies."""
      for kl, penalty in kl_constraints:
          chex.assert_rank(penalty.epsilon, 0)
          chex.assert_type([kl, penalty.alpha, penalty.epsilon], float)
  
      kl_losses, alpha_losses = [], []
      for kl, penalty in kl_constraints:
          kl_loss, alpha_loss, _ = kl_constraint_loss(
              kl, penalty, projection_operator, use_stop_gradient
          )
          kl_losses.append(kl_loss)
          alpha_losses.append(alpha_loss)
      kl_loss, alpha_loss = sum(kl_losses), sum(alpha_losses)
      return kl_loss, alpha_loss
  
file_path: rlax/rlax/_src/mpo_ops.py
imports: import functools
  from typing import Callable, NamedTuple, Optional, Sequence, Tuple
  from absl import logging
  import chex
  import jax
  import jax.numpy
  from rlax._src import base
label_desc: Use image node_id 3 for calling a global function with example usage: compute_parametric_kl_penalty_and_dual_loss(kl_constraints, projection_operator, use_stop_gradient) and returns: kl_loss,  alpha_loss