code: def test_model_rope_scaling(self, scaling_type):
      (
          config,
          _,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
      short_input = ids_tensor([1, 10], config.vocab_size)
      long_input = ids_tensor(
          [1, int(config.max_position_embeddings * 1.5)],
          config.vocab_size,
      )
  
      set_seed(
          42
      )  # Fixed seed at init time so the two models get the same random weights
      original_model = PersimmonModel(config)
      original_model.to(torch_device)
      original_model.eval()
      original_short_output = original_model(
          short_input
      ).last_hidden_state
      original_long_output = original_model(
          long_input
      ).last_hidden_state
  
      set_seed(
          42
      )  # Fixed seed at init time so the two models get the same random weights
      config.rope_scaling = {"type": scaling_type, "factor": 10.0}
      scaled_model = PersimmonModel(config)
      scaled_model.to(torch_device)
      scaled_model.eval()
      scaled_short_output = scaled_model(short_input).last_hidden_state
      scaled_long_output = scaled_model(long_input).last_hidden_state
  
      # Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
      # maximum sequence length, so the outputs for the short input should match.
      if scaling_type == "dynamic":
          self.assertTrue(
              torch.allclose(
                  original_short_output, scaled_short_output, atol=1e-5
              )
          )
      else:
          self.assertFalse(
              torch.allclose(
                  original_short_output, scaled_short_output, atol=1e-5
              )
          )
  
      # The output should be different for long inputs
      self.assertFalse(
          torch.allclose(
              original_long_output, scaled_long_output, atol=1e-5
          )
      )
  
imports: import gc
  import unittest
  from parameterized import parameterized
  from transformers import PersimmonConfig, is_torch_available, set_seed
  from transformers.testing_utils import backend_empty_cache, require_torch, require_torch_accelerator, require_torch_fp16, slow, torch_device
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 9 for calling the PersimmonModelTest obj's underlying member method code with example usage: obj.test_model_rope_scaling(scaling_type) without return types