code: def test_maml_trpo_pendulum():
      """Test PPO with Pendulum environment."""
      episodes_per_task = 5
      max_episode_length = 100
  
      env = normalize(
          GymEnv(
              HalfCheetahDirEnv(), max_episode_length=max_episode_length
          ),
          expected_action_scale=10.0,
      )
      policy = GaussianMLPPolicy(
          env_spec=env.spec,
          hidden_sizes=(64, 64),
          hidden_nonlinearity=torch.tanh,
          output_nonlinearity=None,
      )
      value_function = GaussianMLPValueFunction(
          env_spec=env.spec, hidden_sizes=(32, 32)
      )
      task_sampler = SetTaskSampler(
          HalfCheetahDirEnv,
          wrapper=lambda env, _: normalize(
              GymEnv(env, max_episode_length=max_episode_length),
              expected_action_scale=10.0,
          ),
      )
  
      sampler = LocalSampler(
          agents=policy,
          envs=env,
          max_episode_length=env.spec.max_episode_length,
      )
  
      trainer = Trainer(snapshot_config)
      algo = MAMLTRPO(
          env=env,
          policy=policy,
          sampler=sampler,
          task_sampler=task_sampler,
          value_function=value_function,
          meta_batch_size=5,
          discount=0.99,
          gae_lambda=1.0,
          inner_lr=0.1,
          num_grad_updates=1,
      )
  
      trainer.setup(algo, env)
      last_avg_ret = trainer.train(
          n_epochs=5, batch_size=episodes_per_task * max_episode_length
      )
  
      assert last_avg_ret > -5
  
      env.close()
  
file_path: garage/tests/garage/torch/algos/test_maml_trpo.py
imports: import pytest
  import torch
  from garage.envs import GymEnv, normalize
  from garage.experiment import SetTaskSampler
  from garage.sampler import LocalSampler
  from garage.torch.algos import MAMLTRPO
  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 tests.fixtures.envs.dummy import DummyMultiTaskBoxEnv
  from garage.envs.mujoco import HalfCheetahDirEnv
label_desc: Use image node_id 1 for calling a global function with example usage: test_maml_trpo_pendulum() without return types