code: 
  
  import random
  import unittest
  
  import torch
  
  from diffusers import IFImgaImgPipeline
  from diffusers.utils import floats_tensor
  from diffusers.utils.import_utils import is_xformers_available
  from diffusers.utils.testing_utils import skip_mps, torch_device
  
  from ..pipeline_params import (
      TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
      TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
  )
  from ..test_pipelines_common import PipelineTesterMixin
  from . import IFPipelineTesterMixin
  @skip_mps
  class 					A_   (      _a ,     _a ,     unittest.TestCase						):
  
  
      '''simple docstring'''
  
  
  
  
  
  
      a__     							=       IFImgaImgPipeline
      a__     							=       TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
      a__     							=       TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
      a__     							=       PipelineTesterMixin.required_optional_params - {"latents"}
  
  
      def      lowerCAmelCase_						(self  )     ->      Tuple:
          return self._get_dummy_components()
  
  
      def      lowerCAmelCase_						(self     ,      lowercase__     ,      lowercase__=0  )     ->      Tuple:
          if str(lowercase__  ).startswith('''mps'''  ):
              __UpperCAmelCase									=			torch.manual_seed(lowercase__  )
          else:
              __UpperCAmelCase									=			torch.Generator(device=lowercase__  ).manual_seed(lowercase__  )
  
          __UpperCAmelCase									=			floats_tensor((1, 3, 32, 32)     ,      rng=random.Random(lowercase__  )  ).to(lowercase__  )
  
          __UpperCAmelCase									=			{
              '''prompt''': '''A painting of a squirrel eating a burger''',
              '''image''': image,
              '''generator''': generator,
              '''num_inference_steps''': 2,
              '''output_type''': '''numpy''',
          }
  
          return inputs
  
  
      def      lowerCAmelCase_						(self  )     ->      Tuple:
          self._test_save_load_optional_components()
  
  
      @unittest.skipIf(
          torch_device != '''cuda''' or not is_xformers_available()     ,      reason='''XFormers attention is only available with CUDA and `xformers` installed'''     ,      )
      def      lowerCAmelCase_						(self  )     ->      List[str]:
          self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3  )
  
  
      @unittest.skipIf(torch_device != '''cuda'''     ,      reason='''float16 requires CUDA'''  )
      def      lowerCAmelCase_						(self  )     ->      int:
          # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
          super().test_save_load_floataa(expected_max_diff=1E-1  )
  
  
      @unittest.skipIf(torch_device != '''cuda'''     ,      reason='''float16 requires CUDA'''  )
      def      lowerCAmelCase_						(self  )     ->      Union[str, Any]:
          super().test_floataa_inference(expected_max_diff=1E-1  )
  
  
      def      lowerCAmelCase_						(self  )     ->      int:
          self._test_attention_slicing_forward_pass(expected_max_diff=1E-2  )
  
  
      def      lowerCAmelCase_						(self  )     ->      str:
          self._test_save_load_local()
  
  
  
  
  
  
      def      lowerCAmelCase_						(self  )     ->      Tuple:
          self._test_inference_batch_single_identical(
              expected_max_diff=1E-2     ,      )
  
  
  
  
  
  
style_context: 
  
  import copy
  
  from ...configuration_utils import PretrainedConfig
  from ...utils import logging
  from ..auto.configuration_auto import AutoConfig
  
  
  A_		:			int										=   logging.get_logger(__name__)
  class 					A_   (      _a						):
  
  
      '''simple docstring'''
  
  
  
  
  
  
      a__     							=       "speech-encoder-decoder"
      a__     							=       True
  
  
      def __init__(self     ,      **lowercase__  )     ->      Optional[int]:
          super().__init__(**lowercase__  )
          if "encoder" not in kwargs or "decoder" not in kwargs:
              raise ValueError(
                  F'''A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and'''
                  F''' `decoder` sub-configurations are passed, but only {kwargs}'''  )
  
          __UpperCAmelCase									=			kwargs.pop('''encoder'''  )
          __UpperCAmelCase									=			encoder_config.pop('''model_type'''  )
          __UpperCAmelCase									=			kwargs.pop('''decoder'''  )
          __UpperCAmelCase									=			decoder_config.pop('''model_type'''  )
  
          __UpperCAmelCase									=			AutoConfig.for_model(lowercase__     ,      **lowercase__  )
          __UpperCAmelCase									=			AutoConfig.for_model(lowercase__     ,      **lowercase__  )
          __UpperCAmelCase									=			True
  
  
      @classmethod
      def      lowerCAmelCase_						(cls     ,      lowercase__     ,      lowercase__     ,      **lowercase__  )     ->      PretrainedConfig:
          logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'''  )
          __UpperCAmelCase									=			True
          __UpperCAmelCase									=			True
  
          return cls(encoder=encoder_config.to_dict()     ,      decoder=decoder_config.to_dict()     ,      **lowercase__  )
  
  
  
  
  
  
      def      lowerCAmelCase_						(self  )     ->      Optional[Any]:
          __UpperCAmelCase									=			copy.deepcopy(self.__dict__  )
          __UpperCAmelCase									=			self.encoder.to_dict()
          __UpperCAmelCase									=			self.decoder.to_dict()
          __UpperCAmelCase									=			self.__class__.model_type
          return output
  
  
  
  
  