class_docstr: Test class for torch algo utility functions.
class_docstr_tok: ["Test","class","for","torch","algo","utility","functions","."]
docstr: Test compute_advantage function.
docstr_tok: ["Test","compute_advantage","function","."]
code: def test_compute_advantages(
      self, num_eps, discount, gae_lambda, rewards_eps, baselines_eps
  ):
      """Test compute_advantage function."""
  
      def get_advantage(discount, gae_lambda, rewards, baselines):
          adv = torch.zeros(rewards.shape)
          for i in range(rewards.shape[0]):
              acc = 0
              for j in range(rewards.shape[1]):
                  acc = acc * discount * gae_lambda
                  acc += rewards[i][-j - 1] - baselines[i][-j - 1]
                  acc += discount * baselines[i][-j] if j else 0
                  adv[i][-j - 1] = acc
          return adv
  
      length = len(rewards_eps)
  
      rewards = torch.Tensor(stack(num_eps, rewards_eps))
      baselines = torch.Tensor(stack(num_eps, baselines_eps))
      expected_adv = get_advantage(
          discount, gae_lambda, rewards, baselines
      )
      computed_adv = compute_advantages(
          discount, gae_lambda, length, baselines, rewards
      )
      assert torch.allclose(expected_adv, computed_adv)
  
imports: import collections
  import numpy
  import pytest
  import torch
  from torch import tensor
  import torch.nn.functional
  from garage.envs import GymEnv, normalize
  from garage.experiment.deterministic import set_seed
  from garage.torch import as_torch_dict, compute_advantages, flatten_to_single_vector, global_device, pad_to_last, product_of_gaussians, set_gpu_mode, state_dict_to, torch_to_np
  import garage.torch._functions
  from garage.torch.policies import DeterministicMLPPolicy
  from tests.fixtures import TfGraphTestCase
label_desc: Use image node_id 1 for calling the TestTorchAlgoUtils obj's underlying member method code with example usage: obj.test_compute_advantages(num_eps, discount, gae_lambda, rewards_eps, baselines_eps) and returns: adv