class_docstr: Tests for TanhGaussianMLPPolicy.
class_docstr_tok: ["Tests","for","TanhGaussianMLPPolicy","."]
docstr: Test Tanh Gaussian Policy get action function.
docstr_tok: ["Test","Tanh","Gaussian","Policy","get","action","function","."]
code: def test_get_action(self, hidden_sizes):
      """Test Tanh Gaussian Policy get action function."""
      env_spec = GymEnv(DummyBoxEnv())
      obs_dim = env_spec.observation_space.flat_dim
      act_dim = env_spec.action_space.flat_dim
      obs = torch.ones(obs_dim, dtype=torch.float32).unsqueeze(0)
      init_std = 2.0
  
      policy = TanhGaussianMLPPolicy(
          env_spec=env_spec,
          hidden_sizes=hidden_sizes,
          init_std=init_std,
          hidden_nonlinearity=None,
          std_parameterization="exp",
          hidden_w_init=nn.init.ones_,
          output_w_init=nn.init.ones_,
      )
      expected_mean = torch.full((act_dim,), 1.0, dtype=torch.float)
      action, prob = policy.get_action(obs)
      assert np.allclose(prob["mean"], expected_mean.numpy(), rtol=1e-3)
      assert action.shape == (act_dim,)
  
file_path: garage/tests/garage/torch/policies/test_tanh_gaussian_mlp_policy.py
imports: import pickle
  import numpy
  import pytest
  import torch
  from torch import nn
  from garage.envs import GymEnv
  from garage.torch.policies import TanhGaussianMLPPolicy
  from tests.fixtures.envs.dummy import DummyBoxEnv, DummyDictEnv
label_desc: Use image node_id 1 for calling the TestTanhGaussianMLPPolicy obj's underlying member method code with example usage: obj.test_get_action(hidden_sizes) without return types