class_docstr: Tests that diffusers StableDiffusion model works with PEFT as expected.
code: def test_merge_layers(
      self, test_name, model_id, config_cls, config_kwargs
  ):
      # Instantiate model & adapters
      model = self.instantiate_sd_peft(
          model_id, config_cls, config_kwargs
      )
  
      # Generate output for peft modified StableDiffusion
      dummy_input = self.prepare_inputs_for_testing()
      with temp_seed(seed=42):
          peft_output = np.array(model(**dummy_input).images[0]).astype(
              np.float32
          )
  
      # Merge adapter and model
      if config_cls not in [LoHaConfig, OFTConfig]:
          # TODO: Merging the text_encoder is leading to issues on CPU with PyTorch 2.1
          model.text_encoder = model.text_encoder.merge_and_unload()
      model.unet = model.unet.merge_and_unload()
  
      # Generate output for peft merged StableDiffusion
      with temp_seed(seed=42):
          merged_output = np.array(
              model(**dummy_input).images[0]
          ).astype(np.float32)
  
      # Images are in uint8 drange, so use large atol
      self.assertTrue(np.allclose(peft_output, merged_output, atol=1.0))
  
file_path: peft/tests/test_stablediffusion.py
imports: from dataclasses import asdict, replace
  from unittest import TestCase
  import numpy
  from diffusers import StableDiffusionPipeline
  from parameterized import parameterized
  from peft import LoHaConfig, LoraConfig, OFTConfig, get_peft_model
  from .testing_common import ClassInstantier, PeftCommonTester
  from .testing_utils import temp_seed
label_desc: Use image node_id 3 for calling the StableDiffusionModelTester obj's underlying member method code with example usage: obj.test_merge_layers(test_name, model_id, config_cls, config_kwargs) without return types