code: def test_buffer_actions_scaling(model_class, model_kwargs):
      """
      Test if actions are scaled to tanh co-domain before being put in a buffer
      for algorithms that use tanh-squashing, i.e., DDPG, TD3, SAC
  
      :param model_class: (BaseRLModel) A RL Model
      :param model_kwargs: (dict) Dictionary containing named arguments to the given algorithm
      """
  
      # check random and inferred actions as they possibly have different flows
      for random_coeff in [0.0, 1.0]:
          env = IdentityEnvBox(-2000, 1000)
  
          model = model_class(
              "MlpPolicy",
              env,
              seed=1,
              random_exploration=random_coeff,
              **model_kwargs,
          )
          model.learn(total_timesteps=ROLLOUT_STEPS)
  
          assert hasattr(model, "replay_buffer")
  
          buffer = model.replay_buffer
  
          assert buffer.can_sample(ROLLOUT_STEPS)
  
          _, actions, _, _, _ = buffer.sample(ROLLOUT_STEPS)
  
          assert not np.any(actions > np.ones_like(actions))
          assert not np.any(actions < -np.ones_like(actions))
  
imports: import pytest
  import numpy
  from stable_baselines import DDPG, TD3, SAC
  from stable_baselines.common.identity_env import IdentityEnvBox
label_desc: Use image node_id 1 for calling a global function with example usage: test_buffer_actions_scaling(model_class, model_kwargs) without return types