class_docstr: Test class for MAML-VPG.
class_docstr_tok: ["Test","class","for","MAML-VPG","."]
docstr: Test PPO with Pendulum environment.
docstr_tok: ["Test","PPO","with","Pendulum","environment","."]
code: def test_ppo_pendulum(self):
      """Test PPO with Pendulum environment."""
      deterministic.set_seed(0)
  
      episodes_per_task = 5
      max_episode_length = self.env.spec.max_episode_length
  
      task_sampler = SetTaskSampler(
          HalfCheetahDirEnv,
          wrapper=lambda env, _: normalize(
              GymEnv(env, max_episode_length=max_episode_length),
              expected_action_scale=10.0,
          ),
      )
  
      meta_evaluator = MetaEvaluator(
          test_task_sampler=task_sampler,
          n_test_tasks=1,
          n_test_episodes=10,
      )
      sampler = LocalSampler(
          agents=self.policy,
          envs=self.env,
          max_episode_length=self.env.spec.max_episode_length,
      )
      trainer = Trainer(snapshot_config)
      algo = MAMLVPG(
          env=self.env,
          policy=self.policy,
          sampler=sampler,
          task_sampler=self.task_sampler,
          value_function=self.value_function,
          meta_batch_size=5,
          discount=0.99,
          gae_lambda=1.0,
          inner_lr=0.1,
          num_grad_updates=1,
          meta_evaluator=meta_evaluator,
      )
  
      trainer.setup(algo, self.env)
      last_avg_ret = trainer.train(
          n_epochs=10, batch_size=episodes_per_task * max_episode_length
      )
  
      assert last_avg_ret > -5
  
file_path: garage/tests/garage/torch/algos/test_maml_vpg.py
imports: import pytest
  import torch
  from garage.envs import GymEnv, normalize
  from garage.experiment import deterministic, MetaEvaluator, SetTaskSampler
  from garage.sampler import LocalSampler
  from garage.torch.algos import MAMLVPG
  from garage.torch.policies import GaussianMLPPolicy
  from garage.torch.value_functions import GaussianMLPValueFunction
  from garage.trainer import Trainer
  from tests.fixtures import snapshot_config
  from garage.envs.mujoco import HalfCheetahDirEnv
label_desc: Use image node_id 3 for calling the TestMAMLVPG obj's underlying member method code with example usage: obj.test_ppo_pendulum() without return types