docstr: Test-runs a2c on cartpole.
docstr_tok: ["Test-runs","a2c","on","cartpole","."]
code: def test_sanity_a2ctrainer_cartpole(self):
      """Test-runs a2c on cartpole."""
      task = rl_task.RLTask(
          "CartPole-v0", initial_trajectories=0, max_steps=2
      )
      body = lambda mode: tl.Serial(tl.Dense(64), tl.Relu())
      policy_model = functools.partial(models.Policy, body=body)
      value_model = functools.partial(models.Value, body=body)
      lr = lambda: lr_schedules.multifactor(  # pylint: disable=g-long-lambda
          constant=1e-4,
          warmup_steps=100,
          factors="constant * linear_warmup",
      )
      trainer = actor_critic.A2C(
          task,
          n_shared_layers=1,
          value_model=value_model,
          value_optimizer=opt.Adam,
          value_lr_schedule=lr,
          value_batch_size=2,
          value_train_steps_per_epoch=2,
          policy_model=policy_model,
          policy_optimizer=opt.Adam,
          policy_lr_schedule=lr,
          policy_batch_size=2,
          policy_train_steps_per_epoch=2,
          n_trajectories_per_epoch=2,
      )
      trainer.run(2)
      self.assertEqual(2, trainer.current_epoch)
  
imports: import functools
  from absl.testing import absltest
  from absl.testing import parameterized
  from trax import layers
  from trax import models
  from trax import optimizers
  from trax import test_utils
  from trax.rl import actor_critic
  from trax.rl import advantages
  from trax.rl import task
  from trax.supervised import lr_schedules
label_desc: Use image node_id 3 for calling the ActorCriticTest obj's underlying member method code with example usage: obj.test_sanity_a2ctrainer_cartpole() without return types