


'''simple docstring'''






from __future__ import annotations

import inspect
import unittest
from math import floor

import numpy as np

from transformers import CvtConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
 import tensorflow as tf

 from transformers import TFCvtForImageClassification, TFCvtModel
 from transformers.models.cvt.modeling_tf_cvt import TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import AutoImageProcessor






class    __magic_name__				(						lowerCAmelCase							):






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  int				       =self.config_class(**self.inputs_dict)
          self.parent.assertTrue(hasattr(snake_case    ,				'embed_dim'))
          self.parent.assertTrue(hasattr(snake_case    ,				'num_heads'))






class    __magic_name__				:






       def __init__(     self    ,				snake_case    ,				snake_case=1_3    ,				snake_case=6_4    ,				snake_case=3    ,				snake_case=[1_6, 4_8, 9_6]    ,				snake_case=[1, 3, 6]    ,				snake_case=[1, 2, 1_0]    ,				snake_case=[7, 3, 3]    ,				snake_case=[4, 2, 2]    ,				snake_case=[2, 1, 1]    ,				snake_case=[2, 2, 2]    ,				snake_case=[False, False, True]    ,				snake_case=[0.0, 0.0, 0.0]    ,				snake_case=0.02    ,				snake_case=1E-1_2    ,				snake_case=True    ,				snake_case=True    ,				snake_case=2    ,				)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Dict				       =parent
          _UpperCAmelCase  :  Tuple				       =batch_size
          _UpperCAmelCase  :  List[str]				       =image_size
          _UpperCAmelCase  :  Tuple				       =patch_sizes
          _UpperCAmelCase  :  Any				       =patch_stride
          _UpperCAmelCase  :  Optional[int]				       =patch_padding
          _UpperCAmelCase  :  Tuple				       =is_training
          _UpperCAmelCase  :  Any				       =use_labels
          _UpperCAmelCase  :  Tuple				       =num_labels
          _UpperCAmelCase  :  int				       =num_channels
          _UpperCAmelCase  :  List[Any]				       =embed_dim
          _UpperCAmelCase  :  List[Any]				       =num_heads
          _UpperCAmelCase  :  Optional[int]				       =stride_kv
          _UpperCAmelCase  :  Optional[Any]				       =depth
          _UpperCAmelCase  :  Optional[int]				       =cls_token
          _UpperCAmelCase  :  List[Any]				       =attention_drop_rate
          _UpperCAmelCase  :  List[str]				       =initializer_range
          _UpperCAmelCase  :  Tuple				       =layer_norm_eps






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[int]				       =floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

          _UpperCAmelCase  :  str				       =None
          if self.use_labels:
             # create a random int32 tensor of given shape
             _UpperCAmelCase  :  Optional[Any]				       =ids_tensor([self.batch_size]    ,				self.num_labels)

          _UpperCAmelCase  :  Dict				       =self.get_config()
          return config, pixel_values, labels






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          return CvtConfig(
              image_size=self.image_size    ,				num_labels=self.num_labels    ,				num_channels=self.num_channels    ,				embed_dim=self.embed_dim    ,				num_heads=self.num_heads    ,				patch_sizes=self.patch_sizes    ,				patch_padding=self.patch_padding    ,				patch_stride=self.patch_stride    ,				stride_kv=self.stride_kv    ,				depth=self.depth    ,				cls_token=self.cls_token    ,				attention_drop_rate=self.attention_drop_rate    ,				initializer_range=self.initializer_range    ,				)






       def      lowerCAmelCase						(     self    ,				snake_case    ,				snake_case    ,				snake_case)		->    Tuple:




          '''simple docstring'''
          _UpperCAmelCase  :  str				       =TFCvtModel(config=snake_case)
          _UpperCAmelCase  :  Optional[int]				       =model(snake_case    ,				training=snake_case)
          _UpperCAmelCase  :  Union[str, Any]				       =(self.image_size, self.image_size)
          _UpperCAmelCase       ,			_UpperCAmelCase  :  List[Any]				       =image_size[0], image_size[1]
          for i in range(len(self.depth)):
             _UpperCAmelCase  :  Optional[int]				       =floor(((height + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1)
             _UpperCAmelCase  :  Optional[Any]				       =floor(((width + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1)
          self.parent.assertEqual(result.last_hidden_state.shape    ,				(self.batch_size, self.embed_dim[-1], height, width))






       def      lowerCAmelCase						(     self    ,				snake_case    ,				snake_case    ,				snake_case)		->    Optional[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  List[str]				       =self.num_labels
          _UpperCAmelCase  :  Optional[int]				       =TFCvtForImageClassification(snake_case)
          _UpperCAmelCase  :  List[Any]				       =model(snake_case    ,				labels=snake_case    ,				training=snake_case)
          self.parent.assertEqual(result.logits.shape    ,				(self.batch_size, self.num_labels))






       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[Any]				       =self.prepare_config_and_inputs()
          _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase  :  Any				       =config_and_inputs
          _UpperCAmelCase  :  List[Any]				       ={'pixel_values': pixel_values}
          return config, inputs_dict






@require_tf
class    __magic_name__				(						lowerCAmelCase   ,lowerCAmelCase   ,unittest.TestCase							):
       UpperCAmelCase		 =(TFCvtModel, TFCvtForImageClassification) if is_tf_available() else ()
       UpperCAmelCase		 =(
           {"feature-extraction": TFCvtModel, "image-classification": TFCvtForImageClassification}
           if is_tf_available()
           else {}
       )
       UpperCAmelCase		 =False
       UpperCAmelCase		 =False
       UpperCAmelCase		 =False
       UpperCAmelCase		 =False
       UpperCAmelCase		 =False






       def      lowerCAmelCase						(     self)		->    int:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[Any]				       =TFCvtModelTester(self)
          _UpperCAmelCase  :  Tuple				       =TFCvtConfigTester(self    ,				config_class=snake_case    ,				has_text_modality=snake_case    ,				hidden_size=3_7)






       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          self.config_tester.create_and_test_config_common_properties()
          self.config_tester.create_and_test_config_to_json_string()
          self.config_tester.create_and_test_config_to_json_file()
          self.config_tester.create_and_test_config_from_and_save_pretrained()
          self.config_tester.create_and_test_config_with_num_labels()
          self.config_tester.check_config_can_be_init_without_params()
          self.config_tester.check_config_arguments_init()






       @unittest.skip(reason='Cvt does not output attentions')
       def      lowerCAmelCase						(     self)		->    Dict:




          '''simple docstring'''
          pass






       @unittest.skip(reason='Cvt does not use inputs_embeds')
       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          pass






       @unittest.skip(reason='Cvt does not support input and output embeddings')
       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          pass






       @unittest.skipIf(
           not is_tf_available() or len(tf.config.list_physical_devices('GPU')) == 0    ,				reason='TF does not support backprop for grouped convolutions on CPU.'    ,				)
       def      lowerCAmelCase						(     self)		->    Dict:




          '''simple docstring'''
          super().test_dataset_conversion()






       @unittest.skipIf(
           not is_tf_available() or len(tf.config.list_physical_devices('GPU')) == 0    ,				reason='TF does not support backprop for grouped convolutions on CPU.'    ,				)
       @slow
       def      lowerCAmelCase						(     self)		->    str:




          '''simple docstring'''
          super().test_keras_fit()






       @unittest.skip(reason='Get `Failed to determine best cudnn convolution algo.` error after using TF 2.12+cuda 11.8')
       def      lowerCAmelCase						(     self)		->    int:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[Any]				       =tf.keras.mixed_precision.Policy('mixed_float16')
          tf.keras.mixed_precision.set_global_policy(snake_case)
          super().test_keras_fit()
          tf.keras.mixed_precision.set_global_policy('float32')






       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          _UpperCAmelCase       ,			_UpperCAmelCase  :  int				       =self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
             _UpperCAmelCase  :  Dict				       =model_class(snake_case)
             _UpperCAmelCase  :  Tuple				       =inspect.signature(model.call)
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             _UpperCAmelCase  :  List[Any]				       =[*signature.parameters.keys()]

             _UpperCAmelCase  :  Optional[Any]				       =['pixel_values']
             self.assertListEqual(arg_names[:1]    ,				snake_case)






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          def check_hidden_states_output(snake_case    ,				snake_case    ,				snake_case):
             _UpperCAmelCase  :  Dict				       =model_class(snake_case)

             _UpperCAmelCase  :  List[Any]				       =model(**self._prepare_for_class(snake_case    ,				snake_case))
             _UpperCAmelCase  :  int				       =outputs.hidden_states

             _UpperCAmelCase  :  Optional[Any]				       =len(self.model_tester.depth)
             self.assertEqual(len(snake_case)    ,				snake_case)

             # verify the first hidden states (first block)
             self.assertListEqual(
                 list(hidden_states[0].shape[-3:])    ,				[
                     self.model_tester.embed_dim[0],
                     self.model_tester.image_size // 4,
                     self.model_tester.image_size // 4,
                 ]    ,				)

          _UpperCAmelCase       ,			_UpperCAmelCase  :  List[str]				       =self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
             _UpperCAmelCase  :  Dict				       =True
             check_hidden_states_output(snake_case    ,				snake_case    ,				snake_case)

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             _UpperCAmelCase  :  List[Any]				       =True

             check_hidden_states_output(snake_case    ,				snake_case    ,				snake_case)






       def      lowerCAmelCase						(     self)		->    Tuple:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[int]				       =self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*snake_case)






       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  str				       =self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_image_classification(*snake_case)






       @slow
       def      lowerCAmelCase						(     self)		->    str:




          '''simple docstring'''
          for model_name in TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             _UpperCAmelCase  :  Optional[Any]				       =TFCvtModel.from_pretrained(snake_case)
             self.assertIsNotNone(snake_case)






def lowerCamelCase__     (		):







   '''simple docstring'''




   _UpperCAmelCase  :  Optional[Any]				       =Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'				)
   return image






@require_tf
@require_vision
class    __magic_name__				(						unittest.TestCase							):






       @cached_property
       def      lowerCAmelCase						(     self)		->    Dict:




          '''simple docstring'''
          return AutoImageProcessor.from_pretrained(TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0])






       @slow
       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          _UpperCAmelCase  :  Any				       =TFCvtForImageClassification.from_pretrained(TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0])

          _UpperCAmelCase  :  Union[str, Any]				       =self.default_image_processor
          _UpperCAmelCase  :  Dict				       =prepare_img()
          _UpperCAmelCase  :  Tuple				       =image_processor(images=snake_case    ,				return_tensors='tf')

          # forward pass
          _UpperCAmelCase  :  Optional[Any]				       =model(**snake_case)

          # verify the logits
          _UpperCAmelCase  :  int				       =tf.TensorShape((1, 1_0_0_0))
          self.assertEqual(outputs.logits.shape    ,				snake_case)

          _UpperCAmelCase  :  Dict				       =tf.constant([0.92_85, 0.90_15, -0.31_50])
          self.assertTrue(np.allclose(outputs.logits[0, :3].numpy()    ,				snake_case    ,				atol=1E-4))





'''simple docstring'''






import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import XLMRobertaTokenizerFast

from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel
from diffusers.pipelines.kandinsky.text_encoder import MCLIPConfig, MultilingualCLIP
from diffusers.utils import floats_tensor, load_image, 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    __magic_name__				(						lowerCAmelCase   ,unittest.TestCase							):
       UpperCAmelCase		 =KandinskyImgaImgPipeline
       UpperCAmelCase		 =["prompt", "image_embeds", "negative_image_embeds", "image"]
       UpperCAmelCase		 =[
           "prompt",
           "negative_prompt",
           "image_embeds",
           "negative_image_embeds",
           "image",
       ]
       UpperCAmelCase		 =[
           "generator",
           "height",
           "width",
           "strength",
           "guidance_scale",
           "negative_prompt",
           "num_inference_steps",
           "return_dict",
           "guidance_scale",
           "num_images_per_prompt",
           "output_type",
           "return_dict",
       ]
       UpperCAmelCase		 =False






       @property
       def      lowerCAmelCase						(     self)		->    str:




          '''simple docstring'''
          return 3_2






       @property
       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          return 3_2






       @property
       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          return self.time_input_dim






       @property
       def      lowerCAmelCase						(     self)		->    Optional[int]:




          '''simple docstring'''
          return self.time_input_dim * 4






       @property
       def      lowerCAmelCase						(     self)		->    Tuple:




          '''simple docstring'''
          return 1_0_0






       @property
       def      lowerCAmelCase						(     self)		->    Optional[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  int				       =XLMRobertaTokenizerFast.from_pretrained('YiYiXu/tiny-random-mclip-base')
          return tokenizer






       @property
       def      lowerCAmelCase						(     self)		->    Dict:




          '''simple docstring'''
          torch.manual_seed(0)
          _UpperCAmelCase  :  Optional[Any]				       =MCLIPConfig(
              numDims=self.cross_attention_dim    ,				transformerDimensions=self.text_embedder_hidden_size    ,				hidden_size=self.text_embedder_hidden_size    ,				intermediate_size=3_7    ,				num_attention_heads=4    ,				num_hidden_layers=5    ,				vocab_size=1_0_0_5    ,				)

          _UpperCAmelCase  :  List[Any]				       =MultilingualCLIP(snake_case)
          _UpperCAmelCase  :  List[Any]				       =text_encoder.eval()

          return text_encoder






       @property
       def      lowerCAmelCase						(     self)		->    Optional[Any]:




          '''simple docstring'''
          torch.manual_seed(0)

          _UpperCAmelCase  :  Union[str, Any]				       ={
              'in_channels': 4,
              # Out channels is double in channels because predicts mean and variance
              'out_channels': 8,
              'addition_embed_type': 'text_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': 'text_image_proj',
              'cross_attention_dim': self.cross_attention_dim,
              'attention_head_dim': 4,
              'resnet_time_scale_shift': 'scale_shift',
              'class_embed_type': None,
          }

          _UpperCAmelCase  :  Tuple				       =UNetaDConditionModel(**snake_case)
          return model






       @property
       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''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      lowerCAmelCase						(     self)		->    int:




          '''simple docstring'''
          torch.manual_seed(0)
          _UpperCAmelCase  :  List[Any]				       =VQModel(**self.dummy_movq_kwargs)
          return model






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Tuple				       =self.dummy_text_encoder
          _UpperCAmelCase  :  Any				       =self.dummy_tokenizer
          _UpperCAmelCase  :  List[str]				       =self.dummy_unet
          _UpperCAmelCase  :  Union[str, Any]				       =self.dummy_movq

          _UpperCAmelCase  :  List[str]				       ={
              'num_train_timesteps': 1_0_0_0,
              'beta_schedule': 'linear',
              'beta_start': 0.0_00_85,
              'beta_end': 0.0_12,
              'clip_sample': False,
              'set_alpha_to_one': False,
              'steps_offset': 0,
              'prediction_type': 'epsilon',
              'thresholding': False,
          }

          _UpperCAmelCase  :  Dict				       =DDIMScheduler(**snake_case)

          _UpperCAmelCase  :  Optional[int]				       ={
              'text_encoder': text_encoder,
              'tokenizer': tokenizer,
              'unet': unet,
              'scheduler': scheduler,
              'movq': movq,
          }

          return components






       def      lowerCAmelCase						(     self    ,				snake_case    ,				snake_case=0)		->    int:




          '''simple docstring'''
          _UpperCAmelCase  :  List[Any]				       =floats_tensor((1, self.cross_attention_dim)    ,				rng=random.Random(snake_case)).to(snake_case)
          _UpperCAmelCase  :  Tuple				       =floats_tensor((1, self.cross_attention_dim)    ,				rng=random.Random(seed + 1)).to(snake_case)
          # create init_image
          _UpperCAmelCase  :  Dict				       =floats_tensor((1, 3, 6_4, 6_4)    ,				rng=random.Random(snake_case)).to(snake_case)
          _UpperCAmelCase  :  Optional[int]				       =image.cpu().permute(0    ,				2    ,				3    ,				1)[0]
          _UpperCAmelCase  :  List[Any]				       =Image.fromarray(np.uinta(snake_case)).convert('RGB').resize((2_5_6, 2_5_6))

          if str(snake_case).startswith('mps'):
             _UpperCAmelCase  :  str				       =torch.manual_seed(snake_case)
          else:
             _UpperCAmelCase  :  Optional[Any]				       =torch.Generator(device=snake_case).manual_seed(snake_case)
          _UpperCAmelCase  :  str				       ={
              'prompt': 'horse',
              'image': init_image,
              'image_embeds': image_embeds,
              'negative_image_embeds': negative_image_embeds,
              'generator': generator,
              'height': 6_4,
              'width': 6_4,
              'num_inference_steps': 1_0,
              'guidance_scale': 7.0,
              'strength': 0.2,
              'output_type': 'np',
          }
          return inputs






       def      lowerCAmelCase						(     self)		->    str:




          '''simple docstring'''
          _UpperCAmelCase  :  List[Any]				       ='cpu'

          _UpperCAmelCase  :  Dict				       =self.get_dummy_components()

          _UpperCAmelCase  :  Optional[Any]				       =self.pipeline_class(**snake_case)
          _UpperCAmelCase  :  List[str]				       =pipe.to(snake_case)

          pipe.set_progress_bar_config(disable=snake_case)

          _UpperCAmelCase  :  List[Any]				       =pipe(**self.get_dummy_inputs(snake_case))
          _UpperCAmelCase  :  List[str]				       =output.images

          _UpperCAmelCase  :  Any				       =pipe(
              **self.get_dummy_inputs(snake_case)    ,				return_dict=snake_case    ,				)[0]

          _UpperCAmelCase  :  Any				       =image[0, -3:, -3:, -1]
          _UpperCAmelCase  :  Tuple				       =image_from_tuple[0, -3:, -3:, -1]

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

          _UpperCAmelCase  :  List[Any]				       =np.array(
              [0.61_47_49_43, 0.6_07_35_39, 0.43_30_85_44, 0.5_92_82_69, 0.47_49_35_95, 0.46_75_59_73, 0.4_61_38_38, 0.45_36_87_97, 0.50_11_92_33])
          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    __magic_name__				(						unittest.TestCase							):






       def      lowerCAmelCase						(     self)		->    Optional[int]:




          '''simple docstring'''
          # clean up the VRAM after each test
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()






       def      lowerCAmelCase						(     self)		->    Optional[int]:




          '''simple docstring'''
          _UpperCAmelCase  :  Tuple				       =load_numpy(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
              '/kandinsky/kandinsky_img2img_frog.npy')

          _UpperCAmelCase  :  List[Any]				       =load_image(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main' '/kandinsky/cat.png')
          _UpperCAmelCase  :  Union[str, Any]				       ='A red cartoon frog, 4k'

          _UpperCAmelCase  :  Union[str, Any]				       =KandinskyPriorPipeline.from_pretrained(
              'kandinsky-community/kandinsky-2-1-prior'    ,				torch_dtype=torch.floataa)
          pipe_prior.to(snake_case)

          _UpperCAmelCase  :  Optional[Any]				       =KandinskyImgaImgPipeline.from_pretrained(
              'kandinsky-community/kandinsky-2-1'    ,				torch_dtype=torch.floataa)
          _UpperCAmelCase  :  Tuple				       =pipeline.to(snake_case)

          pipeline.set_progress_bar_config(disable=snake_case)

          _UpperCAmelCase  :  List[str]				       =torch.Generator(device='cpu').manual_seed(0)
          _UpperCAmelCase       ,			_UpperCAmelCase  :  List[Any]				       =pipe_prior(
              snake_case    ,				generator=snake_case    ,				num_inference_steps=5    ,				negative_prompt=''    ,				).to_tuple()

          _UpperCAmelCase  :  str				       =pipeline(
              snake_case    ,				image=snake_case    ,				image_embeds=snake_case    ,				negative_image_embeds=snake_case    ,				generator=snake_case    ,				num_inference_steps=1_0_0    ,				height=7_6_8    ,				width=7_6_8    ,				strength=0.2    ,				output_type='np'    ,				)

          _UpperCAmelCase  :  Any				       =output.images[0]

          assert image.shape == (7_6_8, 7_6_8, 3)

          assert_mean_pixel_difference(snake_case    ,				snake_case)

