code: def test_custom_policy_kwargs(request, model_name):
      """
      Test if the algorithm (with a custom policy) can be loaded and saved without any issues.
      :param model_name: (str) A RL model
      """
  
      model_fname = "./test_model_{}.zip".format(request.node.name)
  
      try:
          model_class, policy, policy_kwargs = MODEL_DICT[model_name]
          env = (
              "MountainCarContinuous-v0"
              if model_name in ["ddpg", "sac"]
              else "CartPole-v1"
          )
  
          # Should raise an error when a wrong keyword is passed
          with pytest.raises(ValueError):
              model_class(
                  policy,
                  env,
                  policy_kwargs=dict(this_throws_error="maybe"),
              )
  
          # create and train
          model = model_class(policy, env, policy_kwargs=policy_kwargs)
          model.learn(total_timesteps=100)
  
          model.save(model_fname)
          del model
  
          # loading
  
          env = DummyVecEnv([lambda: gym.make(env)])
  
          # Load with specifying policy_kwargs
          model = model_class.load(
              model_fname,
              policy=policy,
              env=env,
              policy_kwargs=policy_kwargs,
          )
          model.learn(total_timesteps=100)
          del model
  
          # Load without specifying policy_kwargs
          model = model_class.load(model_fname, policy=policy, env=env)
          model.learn(total_timesteps=100)
          del model
  
          # Load with different wrong policy_kwargs
          with pytest.raises(ValueError):
              _ = model_class.load(
                  model_fname,
                  policy=policy,
                  env=env,
                  policy_kwargs=dict(wrong="kwargs"),
              )
  
      finally:
          if os.path.exists(model_fname):
              os.remove(model_fname)
  
imports: import os
  import gym
  import pytest
  import tensorflow
  from stable_baselines import A2C, ACER, ACKTR, DQN, PPO1, PPO2, TRPO, SAC, DDPG
  from stable_baselines.common.policies import FeedForwardPolicy
  from stable_baselines.common.vec_env import DummyVecEnv
  from stable_baselines.deepq.policies import FeedForwardPolicy
  from stable_baselines.ddpg.policies import FeedForwardPolicy
  from stable_baselines.sac.policies import FeedForwardPolicy
label_desc: Use image node_id 2 for calling a global function with example usage: test_custom_policy_kwargs(request, model_name) without return types