def test_ppo(clip_ratio, dual_clip):
    """
    **Overview**:
        Test function of PPO, for both forward and backward operations.
    """
    # batch size=4, action=32
    B, N = 4, 32
    # Generate logit_new, logit_old, action, adv.
    logit_new = torch.randn(B, N).requires_grad_(True)
    logit_old = logit_new + torch.rand_like(logit_new) * 0.1
    action = torch.randint(0, N, size=(B, ))
    adv = torch.rand(B)
    data = ppo_policy_data(logit_new, logit_old, action, adv, None)
    # Compute PPO error.
    loss, info = ppo_policy_error(data, clip_ratio=clip_ratio, dual_clip=dual_clip)
    # Assert the loss is differentiable.
    assert all([np.isscalar(i) for i in info])
    assert logit_new.grad is None
    total_loss = sum(loss)
    total_loss.backward()
    assert isinstance(logit_new.grad, torch.Tensor)

    **Overview**:
        Test function of PPO, for both forward and backward operations.
    
chapter1_overview/ppo.py