def ProbsRatio(dist_inputs, actions, old_log_probs, log_prob_fun):
  """Probability Ratio from the PPO algorithm."""
  # dist_inputs of the shape float32[128,1,18]
  # actions of the shape int32[128,1]
  # and old_log_probs of the shape float32[128,1]
  new_log_probs = NewLogProbs(dist_inputs, actions, log_prob_fun)
  assert new_log_probs.shape == old_log_probs.shape, (
      f'new_log_probs.shape was {new_log_probs.shape} and'
      f'old_log_probs.shape was {old_log_probs.shape}')
  # The ratio between new_probs and old_probs expressed
  # using log_probs and exponentiation
  probs_ratio = jnp.exp(new_log_probs - old_log_probs)
  return probs_ratio
Probability Ratio from the PPO algorithm.
trax/rl/rl_layers.py