import unittest

from diffusers.models.unet_ad_blocks import *  # noqa F403
from diffusers.utils import torch_device

from .test_unet_blocks_common import UNetBlockTesterMixin



class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Optional[Any]							  =					DownBlockaD  # noqa F405
  lowercase		:  str							  =					"down"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Any  )     ->					Union[str, Any]:
         A    :  int								=[-0.0_2_3_2, -0.9_8_6_9, 0.8_0_5_4, -0.0_6_3_7, -0.1_6_8_8, -1.4_2_6_4, 0.4_4_7_0, -1.3_3_9_4, 0.0_9_0_4]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  List[str]							  =					ResnetDownsampleBlockaD  # noqa F405
  lowercase		:  Union[str, Any]							  =					"down"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[Any]  )     ->					Dict:
         A    :  Tuple								=[0.0_7_1_0, 0.2_4_1_0, -0.7_3_2_0, -1.0_7_5_7, -1.1_3_4_3, 0.3_5_4_0, -0.0_1_3_3, -0.2_5_7_6, 0.0_9_4_8]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Union[str, Any]							  =					AttnDownBlockaD  # noqa F405
  lowercase		:  Union[str, Any]							  =					"down"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Dict:
         A    :  Dict								=[0.0_6_3_6, 0.8_9_6_4, -0.6_2_3_4, -1.0_1_3_1, 0.0_8_4_4, 0.4_9_3_5, 0.3_4_3_7, 0.0_9_1_1, -0.2_9_5_7]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Dict							  =					CrossAttnDownBlockaD  # noqa F405
  lowercase		:  Tuple							  =					"down"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Any  )     ->					str:
         A	,	A    :  Tuple								=super().prepare_init_args_and_inputs_for_common()
         A    :  Optional[int]								=32
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					Any:
         A    :  Optional[Any]								=[0.2_2_3_8, -0.7_3_9_6, -0.2_2_5_5, -0.3_8_2_9, 0.1_9_2_5, 1.1_6_6_5, 0.0_6_0_3, -0.7_2_9_5, 0.1_9_8_3]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					SimpleCrossAttnDownBlockaD  # noqa F405
  lowercase		:  Dict							  =					"down"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					Optional[Any]:
         return super().get_dummy_input(include_encoder_hidden_states=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[Any]  )     ->					Tuple:
         A	,	A    :  str								=super().prepare_init_args_and_inputs_for_common()
         A    :  Tuple								=32
         return init_dict, inputs_dict







  @unittest.skipIf(torch_device == 'mps'   ,						'MPS result is not consistent'  )
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[Any]  )     ->					Tuple:
         A    :  Dict								=[0.7_9_2_1, -0.0_9_9_2, -0.1_9_6_2, -0.7_6_9_5, -0.4_2_4_2, 0.7_8_0_4, 0.4_7_3_7, 0.2_7_6_5, 0.3_3_3_8]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					SkipDownBlockaD  # noqa F405
  lowercase		:  int							  =					"down"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Tuple:
         return super().get_dummy_input(include_skip_sample=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       str  )     ->					int:
         A    :  Union[str, Any]								=[-0.0_8_4_5, -0.2_0_8_7, -0.2_4_6_5, 0.0_9_7_1, 0.1_9_0_0, -0.0_4_8_4, 0.2_6_6_4, 0.4_1_7_9, 0.5_0_6_9]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					AttnSkipDownBlockaD  # noqa F405
  lowercase		:  str							  =					"down"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					Optional[Any]:
         return super().get_dummy_input(include_skip_sample=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					Optional[int]:
         A    :  Tuple								=[0.5_5_3_9, 0.1_6_0_9, 0.4_9_2_4, 0.0_5_3_7, -0.1_9_9_5, 0.4_0_5_0, 0.0_9_7_9, -0.2_7_2_1, -0.0_6_4_2]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Union[str, Any]							  =					DownEncoderBlockaD  # noqa F405
  lowercase		:  str							  =					"down"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[Any]  )     ->					Dict:
         return super().get_dummy_input(include_temb=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					int:
         A    :  Union[str, Any]								={
             'in_channels': 32,
             'out_channels': 32,
         }
         A    :  int								=self.dummy_input
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					List[Any]:
         A    :  Union[str, Any]								=[1.1_1_0_2, 0.5_3_0_2, 0.4_8_7_2, -0.0_0_2_3, -0.8_0_4_2, 0.0_4_8_3, -0.3_4_8_9, -0.5_6_3_2, 0.7_6_2_6]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  str							  =					AttnDownEncoderBlockaD  # noqa F405
  lowercase		:  List[Any]							  =					"down"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					List[Any]:
         return super().get_dummy_input(include_temb=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[Any]  )     ->					List[Any]:
         A    :  int								={
             'in_channels': 32,
             'out_channels': 32,
         }
         A    :  List[str]								=self.dummy_input
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[Any]  )     ->					int:
         A    :  Tuple								=[0.8_9_6_6, -0.1_4_8_6, 0.8_5_6_8, 0.8_1_4_1, -0.9_0_4_6, -0.1_3_4_2, -0.0_9_7_2, -0.7_4_1_7, 0.1_5_3_8]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  List[str]							  =					UNetMidBlockaD  # noqa F405
  lowercase		:  Union[str, Any]							  =					"mid"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[Any]  )     ->					int:
         A    :  Optional[int]								={
             'in_channels': 32,
             'temb_channels': 1_28,
         }
         A    :  List[str]								=self.dummy_input
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					int:
         A    :  Dict								=[-0.1_0_6_2, 1.7_2_4_8, 0.3_4_9_4, 1.4_5_6_9, -0.0_9_1_0, -1.2_4_2_1, -0.9_9_8_4, 0.6_7_3_6, 1.0_0_2_8]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					UNetMidBlockaDCrossAttn  # noqa F405
  lowercase		:  Optional[Any]							  =					"mid"







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Any  )     ->					Optional[Any]:
         A	,	A    :  str								=super().prepare_init_args_and_inputs_for_common()
         A    :  str								=32
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Dict:
         A    :  Tuple								=[0.0_1_8_7, 2.4_2_2_0, 0.4_4_8_4, 1.1_2_0_3, -0.6_1_2_1, -1.5_1_2_2, -0.8_2_7_0, 0.7_8_5_1, 1.8_3_3_5]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Union[str, Any]							  =					UNetMidBlockaDSimpleCrossAttn  # noqa F405
  lowercase		:  List[str]							  =					"mid"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Tuple  )     ->					Tuple:
         return super().get_dummy_input(include_encoder_hidden_states=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Optional[Any]:
         A	,	A    :  List[Any]								=super().prepare_init_args_and_inputs_for_common()
         A    :  List[str]								=32
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Tuple:
         A    :  Optional[Any]								=[0.7_1_4_3, 1.9_9_7_4, 0.5_4_4_8, 1.3_9_7_7, 0.1_2_8_2, -1.1_2_3_7, -1.4_2_3_8, 0.5_5_3_0, 0.8_8_8_0]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					UpBlockaD  # noqa F405
  lowercase		:  Dict							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       str  )     ->					Union[str, Any]:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					Union[str, Any]:
         A    :  List[Any]								=[-0.2_0_4_1, -0.4_1_6_5, -0.3_0_2_2, 0.0_0_4_1, -0.6_6_2_8, -0.7_0_5_3, 0.1_9_2_8, -0.0_3_2_5, 0.0_5_2_3]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  str							  =					ResnetUpsampleBlockaD  # noqa F405
  lowercase		:  List[str]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[Any]  )     ->					Tuple:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Tuple  )     ->					Any:
         A    :  Optional[Any]								=[0.2_2_8_7, 0.3_5_4_9, -0.1_3_4_6, 0.4_7_9_7, -0.1_7_1_5, -0.9_6_4_9, 0.7_3_0_5, -0.5_8_6_4, -0.6_2_4_4]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Union[str, Any]							  =					CrossAttnUpBlockaD  # noqa F405
  lowercase		:  Optional[int]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Any  )     ->					Optional[Any]:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Dict  )     ->					List[str]:
         A	,	A    :  Tuple								=super().prepare_init_args_and_inputs_for_common()
         A    :  Optional[int]								=32
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					str:
         A    :  str								=[-0.1_4_0_3, -0.3_5_1_5, -0.0_4_2_0, -0.1_4_2_5, 0.3_1_6_7, 0.5_0_9_4, -0.2_1_8_1, 0.5_9_3_1, 0.5_5_8_2]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Optional[Any]							  =					SimpleCrossAttnUpBlockaD  # noqa F405
  lowercase		:  List[Any]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Any  )     ->					Any:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__   ,						include_encoder_hidden_states=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					List[str]:
         A	,	A    :  Any								=super().prepare_init_args_and_inputs_for_common()
         A    :  str								=32
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					Optional[Any]:
         A    :  Dict								=[0.2_6_4_5, 0.1_4_8_0, 0.0_9_0_9, 0.8_0_4_4, -0.9_7_5_8, -0.9_0_8_3, 0.0_9_9_4, -1.1_4_5_3, -0.7_4_0_2]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Any							  =					AttnUpBlockaD  # noqa F405
  lowercase		:  str							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       str  )     ->					Optional[Any]:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  @unittest.skipIf(torch_device == 'mps'   ,						'MPS result is not consistent'  )
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					int:
         A    :  int								=[0.0_9_7_9, 0.1_3_2_6, 0.0_0_2_1, 0.0_6_5_9, 0.2_2_4_9, 0.0_0_5_9, 0.1_1_3_2, 0.5_9_5_2, 0.1_0_3_3]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Optional[int]							  =					SkipUpBlockaD  # noqa F405
  lowercase		:  Union[str, Any]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					List[str]:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[int]  )     ->					Dict:
         A    :  Any								=[-0.0_8_9_3, -0.1_2_3_4, -0.1_5_0_6, -0.0_3_3_2, 0.0_1_2_3, -0.0_2_1_1, 0.0_5_6_6, 0.0_1_4_3, 0.0_3_6_2]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Tuple							  =					AttnSkipUpBlockaD  # noqa F405
  lowercase		:  Dict							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					Dict:
         return super().get_dummy_input(include_res_hidden_states_tuple=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       int  )     ->					Dict:
         A    :  List[str]								=[0.0_3_6_1, 0.0_6_1_7, 0.2_7_8_7, -0.0_3_5_0, 0.0_3_4_2, 0.3_4_2_1, -0.0_8_4_3, 0.0_9_1_3, 0.3_0_1_5]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  Any							  =					UpDecoderBlockaD  # noqa F405
  lowercase		:  Union[str, Any]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[Any]  )     ->					List[Any]:
         return super().get_dummy_input(include_temb=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					List[Any]:
         A    :  Optional[Any]								={'in_channels': 32, 'out_channels': 32}

         A    :  Any								=self.dummy_input
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       Optional[Any]  )     ->					Tuple:
         A    :  Optional[int]								=[0.4_4_0_4, 0.1_9_9_8, -0.9_8_8_6, -0.3_3_2_0, -0.3_1_2_8, -0.7_0_3_4, -0.6_9_5_5, -0.2_3_3_8, -0.3_1_3_7]
         super().test_output(lowercase__  )







class 			SCREAMING_SNAKE_CASE_			(       lowerCAmelCase_ ,    unittest.TestCase      ):
  '''simple docstring'''


  lowercase		:  str							  =					AttnUpDecoderBlockaD  # noqa F405
  lowercase		:  List[Any]							  =					"up"







  @property
  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					List[Any]:
         return super().get_dummy_input(include_temb=lowercase__  )







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					Tuple:
         A    :  List[str]								={'in_channels': 32, 'out_channels': 32}

         A    :  Union[str, Any]								=self.dummy_input
         return init_dict, inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(					self     :       List[str]  )     ->					Optional[Any]:
         A    :  Any								=[0.6_7_3_8, 0.4_4_9_1, 0.1_0_5_5, 1.0_7_1_0, 0.7_3_1_6, 0.3_3_3_9, 0.3_3_5_2, 0.1_0_2_3, 0.3_5_6_8]
         super().test_output(lowercase__  )









import gc
import random
import unittest

import numpy as np
import torch

from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel
from diffusers.utils import floats_tensor, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference


enable_full_determinism()





class        lowerCAmelCase__  (					__magic_name__				,							unittest.TestCase			):



       '''simple docstring'''







       lowercase_						=    KandinskyVaaPipeline
       lowercase_						=    [
           """image_embeds""",
           """negative_image_embeds""",
       ]
       lowercase_						=    ["""image_embeds""", """negative_image_embeds"""]
       lowercase_						=    [
           """generator""",
           """height""",
           """width""",
           """latents""",
           """guidance_scale""",
           """num_inference_steps""",
           """return_dict""",
           """guidance_scale""",
           """num_images_per_prompt""",
           """output_type""",
           """return_dict""",
       ]
       lowercase_						=    False

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return 3_2

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return 3_2

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return self.time_input_dim

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return self.time_input_dim * 4

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return 1_0_0

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             torch.manual_seed(0     )

             __A    ={
                 '''in_channels''': 4,
                 # Out channels is double in channels because predicts mean and variance
                 '''out_channels''': 8,
                 '''addition_embed_type''': '''image''',
                 '''down_block_types''': ('''ResnetDownsampleBlock2D''', '''SimpleCrossAttnDownBlock2D'''),
                 '''up_block_types''': ('''SimpleCrossAttnUpBlock2D''', '''ResnetUpsampleBlock2D'''),
                 '''mid_block_type''': '''UNetMidBlock2DSimpleCrossAttn''',
                 '''block_out_channels''': (self.block_out_channels_a, self.block_out_channels_a * 2),
                 '''layers_per_block''': 1,
                 '''encoder_hid_dim''': self.text_embedder_hidden_size,
                 '''encoder_hid_dim_type''': '''image_proj''',
                 '''cross_attention_dim''': self.cross_attention_dim,
                 '''attention_head_dim''': 4,
                 '''resnet_time_scale_shift''': '''scale_shift''',
                 '''class_embed_type''': None,
             }

             __A    =UNetaDConditionModel(**lowercase__     )
             return model

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return {
                 "block_out_channels": [3_2, 6_4],
                 "down_block_types": ["DownEncoderBlock2D", "AttnDownEncoderBlock2D"],
                 "in_channels": 3,
                 "latent_channels": 4,
                 "layers_per_block": 1,
                 "norm_num_groups": 8,
                 "norm_type": "spatial",
                 "num_vq_embeddings": 1_2,
                 "out_channels": 3,
                 "up_block_types": [
                     "AttnUpDecoderBlock2D",
                     "UpDecoderBlock2D",
                 ],
                 "vq_embed_dim": 4,
             }

       @property
       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             torch.manual_seed(0     )
             __A    =VQModel(**self.dummy_movq_kwargs     )
             return model

       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    =self.dummy_unet
             __A    =self.dummy_movq

             __A    =DDIMScheduler(
                 num_train_timesteps=1_0_0_0 ,   beta_schedule='''linear''' ,   beta_start=0.0_0085 ,   beta_end=0.012 ,   clip_sample=lowercase__ ,   set_alpha_to_one=lowercase__ ,   steps_offset=1 ,   prediction_type='''epsilon''' ,   thresholding=lowercase__ ,   )

             __A    ={
                 '''unet''': unet,
                 '''scheduler''': scheduler,
                 '''movq''': movq,
             }
             return components

       def     __UpperCamelCase     (							self ,   lowercase__ ,   lowercase__=0     ):







             '''simple docstring'''



             __A    =floats_tensor((1, self.text_embedder_hidden_size) ,   rng=random.Random(lowercase__     )     ).to(lowercase__     )
             __A    =floats_tensor((1, self.text_embedder_hidden_size) ,   rng=random.Random(seed + 1     )     ).to(
                 lowercase__     )
             if str(lowercase__     ).startswith('''mps'''     ):
                   __A    =torch.manual_seed(lowercase__     )
             else:
                   __A    =torch.Generator(device=lowercase__     ).manual_seed(lowercase__     )
             __A    ={
                 '''image_embeds''': image_embeds,
                 '''negative_image_embeds''': negative_image_embeds,
                 '''generator''': generator,
                 '''height''': 6_4,
                 '''width''': 6_4,
                 '''guidance_scale''': 4.0,
                 '''num_inference_steps''': 2,
                 '''output_type''': '''np''',
             }
             return inputs


       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    ='''cpu'''

             __A    =self.get_dummy_components()

             __A    =self.pipeline_class(**lowercase__     )
             __A    =pipe.to(lowercase__     )

             pipe.set_progress_bar_config(disable=lowercase__     )

             __A    =pipe(**self.get_dummy_inputs(lowercase__     )     )
             __A    =output.images

             __A    =pipe(
                 **self.get_dummy_inputs(lowercase__     ) ,   return_dict=lowercase__ ,   )[0]

             __A    =image[0, -3:, -3:, -1]
             __A    =image_from_tuple[0, -3:, -3:, -1]

             assert image.shape == (1, 6_4, 6_4, 3)

             __A    =np.array(
                 [0.623_7976, 1.0, 0.3644_1332, 1.0, 0.7063_9634, 0.2987_7186, 0.8565_2125, 0.521_6843, 0.5445_4046]     )

             assert (
                 np.abs(image_slice.flatten() - expected_slice     ).max() < 1E-2
             ), f''' expected_slice {expected_slice}, but got {image_slice.flatten()}'''

             assert (
                 np.abs(image_from_tuple_slice.flatten() - expected_slice     ).max() < 1E-2
             ), f''' expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}'''





@slow
@require_torch_gpu
class        lowerCAmelCase__  (					unittest.TestCase			):



       '''simple docstring'''







       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             super().tearDown()
             gc.collect()
             torch.cuda.empty_cache()


       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    =load_numpy(
                 '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
                 '''/kandinskyv22/kandinskyv22_text2img_cat_fp16.npy'''     )

             __A    =KandinskyVaaPriorPipeline.from_pretrained(
                 '''kandinsky-community/kandinsky-2-2-prior''' ,   torch_dtype=torch.floataa     )
             pipe_prior.to(lowercase__     )

             __A    =KandinskyVaaPipeline.from_pretrained(
                 '''kandinsky-community/kandinsky-2-2-decoder''' ,   torch_dtype=torch.floataa     )
             __A    =pipeline.to(lowercase__     )
             pipeline.set_progress_bar_config(disable=lowercase__     )

             __A    ='''red cat, 4k photo'''

             __A    =torch.Generator(device='''cuda'''     ).manual_seed(0     )
             __A    ,		__A    =pipe_prior(
                 lowercase__ ,   generator=lowercase__ ,   num_inference_steps=5 ,   negative_prompt='''''' ,   ).to_tuple()

             __A    =torch.Generator(device='''cuda'''     ).manual_seed(0     )
             __A    =pipeline(
                 image_embeds=lowercase__ ,   negative_image_embeds=lowercase__ ,   generator=lowercase__ ,   num_inference_steps=1_0_0 ,   output_type='''np''' ,   )

             __A    =output.images[0]

             assert image.shape == (5_1_2, 5_1_2, 3)

             assert_mean_pixel_difference(lowercase__ ,   lowercase__     )


