code: def test_sac_inverted_double_pendulum():
      """Test Sac performance on inverted pendulum."""
      # pylint: disable=unexpected-keyword-arg
      env = normalize(
          GymEnv("InvertedDoublePendulum-v2", max_episode_length=100)
      )
      deterministic.set_seed(0)
      policy = TanhGaussianMLPPolicy(
          env_spec=env.spec,
          hidden_sizes=[32, 32],
          hidden_nonlinearity=torch.nn.ReLU,
          output_nonlinearity=None,
          min_std=np.exp(-20.0),
          max_std=np.exp(2.0),
      )
  
      qf1 = ContinuousMLPQFunction(
          env_spec=env.spec,
          hidden_sizes=[32, 32],
          hidden_nonlinearity=F.relu,
      )
  
      qf2 = ContinuousMLPQFunction(
          env_spec=env.spec,
          hidden_sizes=[32, 32],
          hidden_nonlinearity=F.relu,
      )
      replay_buffer = PathBuffer(
          capacity_in_transitions=int(1e6),
      )
      trainer = Trainer(snapshot_config=snapshot_config)
      sampler = LocalSampler(
          agents=policy,
          envs=env,
          max_episode_length=env.spec.max_episode_length,
          worker_class=FragmentWorker,
      )
      sac = SAC(
          env_spec=env.spec,
          policy=policy,
          qf1=qf1,
          qf2=qf2,
          sampler=sampler,
          gradient_steps_per_itr=100,
          replay_buffer=replay_buffer,
          min_buffer_size=1e3,
          target_update_tau=5e-3,
          discount=0.99,
          buffer_batch_size=64,
          reward_scale=1.0,
          steps_per_epoch=2,
      )
      trainer.setup(sac, env)
      if torch.cuda.is_available():
          set_gpu_mode(True)
      else:
          set_gpu_mode(False)
      sac.to()
      ret = trainer.train(n_epochs=12, batch_size=200, plot=False)
      # check that automatic entropy tuning is used
      assert sac._use_automatic_entropy_tuning
      # assert that there was a gradient properly connected to alpha
      # this doesn't verify that the path from the temperature objective is
      # correct.
      assert not torch.allclose(
          torch.Tensor([1.0]), sac._log_alpha.to("cpu")
      )
      # check that policy is learning beyond predecided threshold
      assert ret > 80
  
imports: from unittest.mock import MagicMock
  import numpy
  import pytest
  import torch
  from torch.nn import functional
  from garage.envs import GymEnv, normalize
  from garage.experiment import deterministic
  from garage.replay_buffer import PathBuffer
  from garage.sampler import FragmentWorker, LocalSampler
  from garage.torch import set_gpu_mode
  from garage.torch.algos import SAC
  from garage.torch.policies import TanhGaussianMLPPolicy
  from garage.torch.q_functions import ContinuousMLPQFunction
  from garage.trainer import Trainer
  from tests.fixtures import snapshot_config
label_desc: Use image node_id 4 for calling a global function with example usage: test_sac_inverted_double_pendulum() without return types