code: def test_model_manipulation(request, model_class):
      """
      Test if the algorithm can be loaded and saved without any issues, the environment switching
      works and that the action prediction works
  
      :param model_class: (BaseRLModel) A model
      """
      model_fname = None
      try:
          env = DummyVecEnv([lambda: IdentityEnvBox(eps=0.5)])
  
          # create and train
          model = model_class(policy="MlpPolicy", env=env, seed=0)
          model.learn(total_timesteps=NUM_TIMESTEPS)
  
          env.reset()
          observations = np.concatenate(
              [
                  env.step([env.action_space.sample()])[0]
                  for _ in range(10)
              ],
              axis=0,
          )
          selected_actions, _ = model.predict(
              observations, deterministic=True
          )
  
          # saving
          model_fname = "./test_model_{}.zip".format(request.node.name)
          model.save(model_fname)
  
          del model, env
  
          # loading
          model = model_class.load(model_fname)
  
          # check if model still selects the same actions
          new_selected_actions, _ = model.predict(
              observations, deterministic=True
          )
          assert np.allclose(
              selected_actions, new_selected_actions, 1e-4
          )
  
          # changing environment (note: this can be done at loading)
          env = DummyVecEnv([lambda: IdentityEnvBox(eps=0.5)])
          model.set_env(env)
  
          obs = env.reset()
          with pytest.warns(None) as record:
              act_prob = model.action_probability(obs)
  
          if model_class in [DDPG, SAC, TD3]:
              # check that only one warning was raised
              assert (
                  len(record) == 1
              ), "No warning was raised for {}".format(model_class)
              assert (
                  act_prob is None
              ), "Error: action_probability should be None for {}".format(
                  model_class
              )
          else:
              assert act_prob[0].shape == (1, 1) and act_prob[
                  1
              ].shape == (
                  1,
                  1,
              ), "Error: action_probability not returning correct shape"
  
          # test action probability for given (obs, action) pair
          # must return zero and raise a warning or raise an exception if not defined
          env = model.get_env()
          obs = env.reset()
          observations = np.array([obs for _ in range(10)])
          observations = np.squeeze(observations)
          observations = observations.reshape((-1, 1))
          actions = np.array(
              [env.action_space.sample() for _ in range(10)]
          )
  
          if model_class in [DDPG, SAC, TD3]:
              with pytest.raises(ValueError):
                  model.action_probability(
                      observations, actions=actions
                  )
          else:
              actions_probas = model.action_probability(
                  observations, actions=actions
              )
              assert actions_probas.shape == (
                  len(actions),
                  1,
              ), actions_probas.shape
              assert np.all(actions_probas >= 0), actions_probas
              actions_logprobas = model.action_probability(
                  observations, actions=actions, logp=True
              )
              assert np.allclose(
                  actions_probas, np.exp(actions_logprobas)
              ), (actions_probas, actions_logprobas)
  
          # learn post loading
          model.learn(total_timesteps=100)
  
          # predict new values
          evaluate_policy(model, env, n_eval_episodes=N_EVAL_EPISODES)
  
          # Free memory
          del model, env
  
      finally:
          if model_fname is not None and os.path.exists(model_fname):
              os.remove(model_fname)
  
file_path: stable-baselines/tests/test_continuous.py
imports: import subprocess
  import os
  import gym
  import pytest
  import numpy
  from stable_baselines import A2C, ACKTR, SAC, DDPG, PPO1, PPO2, TRPO, TD3
  from stable_baselines.common.vec_env import DummyVecEnv
  from stable_baselines.common.identity_env import IdentityEnvBox
  from stable_baselines.ddpg import AdaptiveParamNoiseSpec, NormalActionNoise
  from stable_baselines.common.evaluation import evaluate_policy
  from tests.test_common import _assert_eq
label_desc: Use image node_id 1 for calling a global function with example usage: test_model_manipulation(request, model_class) without return types