code: def test_clipped_ppo_loss_discrete_batch_kl_div():
      # check lower loss for policy with better probabilities:
      # i.e. higher probability on high advantage actions, low probability on low advantage actions.
      loss_fn = ClippedPPOLossDiscrete(
          num_actions=2,
          clip_likelihood_ratio_using_epsilon=None,
          use_kl_regularization=True,
          initial_kl_coefficient=0.5,
      )
      loss_fn.initialize()
  
      # actual actions taken, of shape (batch_size)
      actions = mx.nd.array((0, 1, 0))
      # advantages from taking action, of shape (batch_size)
      advantages = mx.nd.array((-2, 2, 1))
      # action probabilities, of shape (batch_size, num_actions)
      old_policy_probs = mx.nd.array(
          ((0.7, 0.3), (0.2, 0.8), (0.4, 0.6))
      )
      new_policy_probs_worse = mx.nd.array(
          ((0.9, 0.1), (0.2, 0.8), (0.4, 0.6))
      )
      new_policy_probs_better = mx.nd.array(
          ((0.5, 0.5), (0.2, 0.8), (0.4, 0.6))
      )
  
      clip_param_rescaler = mx.nd.array((1,))
  
      loss_worse = loss_fn(
          new_policy_probs_worse,
          actions,
          old_policy_probs,
          clip_param_rescaler,
          advantages,
      )
      loss_better = loss_fn(
          new_policy_probs_better,
          actions,
          old_policy_probs,
          clip_param_rescaler,
          advantages,
      )
  
      assert (
          len(loss_worse) == 6
      )  # (LOSS, REGULARIZATION, KL, ENTROPY, LIKELIHOOD_RATIO, CLIPPED_LIKELIHOOD_RATIO)
      lw_loss, lw_reg, lw_kl, lw_ent, lw_lr, lw_clip_lr = loss_worse
      assert lw_kl.ndim == 1
      assert lw_kl.shape[0] == 1
      assert (
          len(loss_better) == 6
      )  # (LOSS, REGULARIZATION, KL, ENTROPY, LIKELIHOOD_RATIO, CLIPPED_LIKELIHOOD_RATIO)
      lb_loss, lb_reg, lb_kl, lb_ent, lb_lr, lb_clip_lr = loss_better
      assert lb_kl.ndim == 1
      assert lb_kl.shape[0] == 1
      assert lw_kl > lb_kl
      assert lw_reg > lb_reg
  
imports: import mxnet
  import numpy
  import os
  import pytest
  from scipy import stats
  import sys
  from rl_coach.architectures.head_parameters import PPOHeadParameters
  from rl_coach.architectures.mxnet_components.heads.ppo_head import CategoricalDist, MultivariateNormalDist, DiscretePPOHead, ClippedPPOLossDiscrete, ClippedPPOLossContinuous, PPOHead
  from rl_coach.agents.clipped_ppo_agent import ClippedPPOAlgorithmParameters, ClippedPPOAgentParameters
  from rl_coach.spaces import SpacesDefinition, DiscreteActionSpace
label_desc: Use image node_id 14 for calling a global function with example usage: test_clipped_ppo_loss_discrete_batch_kl_div() without return types