





"""simple docstring"""





from __future__ import annotations

import inspect
import unittest
from typing import List, Tuple

from transformers import RegNetConfig
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 TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST, TFRegNetForImageClassification, TFRegNetModel


if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor
class 		SCREAMING_SNAKE_CASE_							:
				"""simple docstring"""




				def __init__(     self  :Any						,    __lowercase  :str						,    __lowercase  :Optional[Any]=3						,    __lowercase  :Dict=32						,    __lowercase  :List[str]=3						,    __lowercase  :int=10						,    __lowercase  :List[str]=[10, 20, 30, 40]						,    __lowercase  :int=[1, 1, 2, 1]						,    __lowercase  :int=True						,    __lowercase  :Dict=True						,    __lowercase  :Tuple="relu"						,    __lowercase  :Union[str, Any]=3						,    __lowercase  :Any=None						,    ):
											__lowerCamelCase      :      Dict         =parent
											__lowerCamelCase      :      Tuple         =batch_size
											__lowerCamelCase      :      List[Any]         =image_size
											__lowerCamelCase      :      Any         =num_channels
											__lowerCamelCase      :      Dict         =embeddings_size
											__lowerCamelCase      :      Dict         =hidden_sizes
											__lowerCamelCase      :      List[Any]         =depths
											__lowerCamelCase      :      List[str]         =is_training
											__lowerCamelCase      :      Union[str, Any]         =use_labels
											__lowerCamelCase      :      List[str]         =hidden_act
											__lowerCamelCase      :      Any         =num_labels
											__lowerCamelCase      :      Any         =scope
											__lowerCamelCase      :      Optional[Any]         =len(__lowercase			)




				def 					__lowercase  (     self  :Optional[Any]			):
											__lowerCamelCase      :      str         =floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

											__lowerCamelCase      :      Union[str, Any]         =None
											if self.use_labels:
																		__lowerCamelCase      :      int         =ids_tensor([self.batch_size]						,    self.num_labels			)

											__lowerCamelCase      :      Tuple         =self.get_config()
											return config, pixel_values, labels




				def 					__lowercase  (     self  :int			):
											return RegNetConfig(
											    num_channels=self.num_channels						,    embeddings_size=self.embeddings_size						,    hidden_sizes=self.hidden_sizes						,    depths=self.depths						,    hidden_act=self.hidden_act						,    num_labels=self.num_labels						,    )




				def 					__lowercase  (     self  :Union[str, Any]						,    __lowercase  :Tuple						,    __lowercase  :Union[str, Any]						,    __lowercase  :List[Any]			):
											__lowerCamelCase      :      Dict         =TFRegNetModel(config=__lowercase			)
											__lowerCamelCase      :      Tuple         =model(__lowercase						,    training=__lowercase			)
											# expected last hidden states: B, C, H // 32, W // 32
											self.parent.assertEqual(
											    result.last_hidden_state.shape						,    (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)						,    )




				def 					__lowercase  (     self  :Any						,    __lowercase  :Optional[Any]						,    __lowercase  :Optional[Any]						,    __lowercase  :Tuple			):
											__lowerCamelCase      :      int         =self.num_labels
											__lowerCamelCase      :      Any         =TFRegNetForImageClassification(__lowercase			)
											__lowerCamelCase      :      Dict         =model(__lowercase						,    labels=__lowercase						,    training=__lowercase			)
											self.parent.assertEqual(result.logits.shape						,    (self.batch_size, self.num_labels)			)




				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase      :      Union[str, Any]         =self.prepare_config_and_inputs()
											__lowerCamelCase    ,						__lowerCamelCase    ,						__lowerCamelCase      :      Tuple         =config_and_inputs
											__lowerCamelCase      :      List[Any]         ={'''pixel_values''': pixel_values}
											return config, inputs_dict

@require_tf
class 		SCREAMING_SNAKE_CASE_							(    snake_case__       ,  snake_case__       ,  unittest.TestCase   ):
				"""simple docstring"""
				__snake_case   :       List[str]	 =		(TFRegNetModel, TFRegNetForImageClassification) if is_tf_available() else ()
				__snake_case   :       str	 =		(
				    {"""feature-extraction""": TFRegNetModel, """image-classification""": TFRegNetForImageClassification}
				    if is_tf_available()
				    else {}
				)

				__snake_case   :       Any	 =		False
				__snake_case   :       List[str]	 =		False
				__snake_case   :       int	 =		False
				__snake_case   :       Optional[Any]	 =		False
				__snake_case   :       Optional[int]	 =		False




				def 					__lowercase  (     self  :Dict			):
											__lowerCamelCase      :      Dict         =TFRegNetModelTester(self			)
											__lowerCamelCase      :      Union[str, Any]         =ConfigTester(self						,    config_class=__lowercase						,    has_text_modality=__lowercase			)




				def 					__lowercase  (     self  :Union[str, Any]			):
											return




				@unittest.skip(reason='''RegNet does not use inputs_embeds'''			)
				def 					__lowercase  (     self  :List[str]			):
											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.'''						,    )
				@slow
				def 					__lowercase  (     self  :Optional[Any]			):
											super().test_keras_fit()




				@unittest.skip(reason='''RegNet does not support input and output embeddings'''			)
				def 					__lowercase  (     self  :int			):
											pass




				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase    ,						__lowerCamelCase      :      str         =self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		__lowerCamelCase      :      int         =model_class(__lowercase			)
																		__lowerCamelCase      :      str         =inspect.signature(model.call			)
																		# signature.parameters is an OrderedDict => so arg_names order is deterministic
																		__lowerCamelCase      :      List[str]         =[*signature.parameters.keys()]

																		__lowerCamelCase      :      int         =['''pixel_values''']
																		self.assertListEqual(arg_names[:1]						,    __lowercase			)




				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase      :      str         =self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*__lowercase			)




				def 					__lowercase  (     self  :List[str]			):
											def check_hidden_states_output(__lowercase  :Dict						,    __lowercase  :List[str]						,    __lowercase  :Union[str, Any]			):
																		__lowerCamelCase      :      List[str]         =model_class(__lowercase			)
																		__lowerCamelCase      :      int         =model(**self._prepare_for_class(__lowercase						,    __lowercase			)						,    training=__lowercase			)

																		__lowerCamelCase      :      Any         =outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

																		__lowerCamelCase      :      Union[str, Any]         =self.model_tester.num_stages
																		self.assertEqual(len(__lowercase			)						,    expected_num_stages + 1			)

																		# RegNet's feature maps are of shape (batch_size, num_channels, height, width)
																		self.assertListEqual(
																		    list(hidden_states[0].shape[-2:]			)						,    [self.model_tester.image_size // 2, self.model_tester.image_size // 2]						,    )

											__lowerCamelCase    ,						__lowerCamelCase      :      Dict         =self.model_tester.prepare_config_and_inputs_for_common()
											__lowerCamelCase      :      Optional[Any]         =['''basic''', '''bottleneck''']
											for model_class in self.all_model_classes:
																		for layer_type in layers_type:
																									__lowerCamelCase      :      Tuple         =layer_type
																									__lowerCamelCase      :      Any         =True
																									check_hidden_states_output(__lowercase						,    __lowercase						,    __lowercase			)

																									# check that output_hidden_states also work using config
																									del inputs_dict["output_hidden_states"]
																									__lowerCamelCase      :      int         =True

																									check_hidden_states_output(__lowercase						,    __lowercase						,    __lowercase			)




				def 					__lowercase  (     self  :str			):
											__lowerCamelCase    ,						__lowerCamelCase      :      Union[str, Any]         =self.model_tester.prepare_config_and_inputs_for_common()

											def check_equivalence(__lowercase  :Dict						,    __lowercase  :List[str]						,    __lowercase  :int						,    __lowercase  :Optional[Any]={}			):
																		__lowerCamelCase      :      Optional[Any]         =model(__lowercase						,    return_dict=__lowercase						,    **__lowercase			)
																		__lowerCamelCase      :      Optional[Any]         =model(__lowercase						,    return_dict=__lowercase						,    **__lowercase			).to_tuple()

																		def recursive_check(__lowercase  :str						,    __lowercase  :Tuple			):
																									if isinstance(__lowercase						,    (List, Tuple)			):
																																for tuple_iterable_value, dict_iterable_value in zip(__lowercase						,    __lowercase			):
																																							recursive_check(__lowercase						,    __lowercase			)
																									elif tuple_object is None:
																																return
																									else:
																																self.assertTrue(
																																    all(tf.equal(__lowercase						,    __lowercase			)			)						,    msg=(
																																        '''Tuple and dict output are not equal. Difference:'''
																																        f' {tf.math.reduce_max(tf.abs(tuple_object - dict_object			)			)}'
																																    )						,    )

																									recursive_check(__lowercase						,    __lowercase			)

											for model_class in self.all_model_classes:
																		__lowerCamelCase      :      Tuple         =model_class(__lowercase			)

																		__lowerCamelCase      :      List[Any]         =self._prepare_for_class(__lowercase						,    __lowercase			)
																		__lowerCamelCase      :      Optional[Any]         =self._prepare_for_class(__lowercase						,    __lowercase			)
																		check_equivalence(__lowercase						,    __lowercase						,    __lowercase			)

																		__lowerCamelCase      :      int         =self._prepare_for_class(__lowercase						,    __lowercase						,    return_labels=__lowercase			)
																		__lowerCamelCase      :      Any         =self._prepare_for_class(__lowercase						,    __lowercase						,    return_labels=__lowercase			)
																		check_equivalence(__lowercase						,    __lowercase						,    __lowercase			)

																		__lowerCamelCase      :      Union[str, Any]         =self._prepare_for_class(__lowercase						,    __lowercase			)
																		__lowerCamelCase      :      Dict         =self._prepare_for_class(__lowercase						,    __lowercase			)
																		check_equivalence(__lowercase						,    __lowercase						,    __lowercase						,    {'''output_hidden_states''': True}			)

																		__lowerCamelCase      :      Tuple         =self._prepare_for_class(__lowercase						,    __lowercase						,    return_labels=__lowercase			)
																		__lowerCamelCase      :      Optional[Any]         =self._prepare_for_class(__lowercase						,    __lowercase						,    return_labels=__lowercase			)
																		check_equivalence(__lowercase						,    __lowercase						,    __lowercase						,    {'''output_hidden_states''': True}			)




				def 					__lowercase  (     self  :Tuple			):
											__lowerCamelCase      :      List[Any]         =self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_image_classification(*__lowercase			)




				@slow
				def 					__lowercase  (     self  :List[Any]			):
											for model_name in TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		__lowerCamelCase      :      Any         =TFRegNetModel.from_pretrained(__lowercase			)
																		self.assertIsNotNone(__lowercase			)



def 				lowerCAmelCase_			(      ):


							'''simple docstring'''







							__lowerCamelCase      :      Union[str, Any]         =Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''   )
							return image
@require_tf
@require_vision
class 		SCREAMING_SNAKE_CASE_							(    unittest.TestCase   ):
				"""simple docstring"""




				@cached_property
				def 					__lowercase  (     self  :Union[str, Any]			):
											return (
											    AutoImageProcessor.from_pretrained(TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)
											    if is_vision_available()
											    else None
											)




				@slow
				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase      :      List[Any]         =TFRegNetForImageClassification.from_pretrained(TF_REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)

											__lowerCamelCase      :      Optional[int]         =self.default_image_processor
											__lowerCamelCase      :      int         =prepare_img()
											__lowerCamelCase      :      str         =image_processor(images=__lowercase						,    return_tensors='''tf'''			)

											# forward pass
											__lowerCamelCase      :      int         =model(**__lowercase						,    training=__lowercase			)

											# verify the logits
											__lowerCamelCase      :      Optional[Any]         =tf.TensorShape((1, 1000)			)
											self.assertEqual(outputs.logits.shape						,    __lowercase			)

											__lowerCamelCase      :      Dict         =tf.constant([-0.4180, -1.5051, -3.4836]			)

											tf.debugging.assert_near(outputs.logits[0, :3]						,    __lowercase						,    atol=1e-4			)











"""simple docstring"""





import gc
import random
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel
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, skip_mps

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()
class 		SCREAMING_SNAKE_CASE_							(    snake_case__       ,  snake_case__       ,  unittest.TestCase   ):
				"""simple docstring"""
				__snake_case   :       Dict	 =		CycleDiffusionPipeline
				__snake_case   :       Optional[int]	 =		TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {
				    """negative_prompt""",
				    """height""",
				    """width""",
				    """negative_prompt_embeds""",
				}
				__snake_case   :       Any	 =		PipelineTesterMixin.required_optional_params - {"""latents"""}
				__snake_case   :       int	 =		TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS.union({"""source_prompt"""}   )
				__snake_case   :       Optional[int]	 =		IMAGE_TO_IMAGE_IMAGE_PARAMS
				__snake_case   :       str	 =		IMAGE_TO_IMAGE_IMAGE_PARAMS




				def 					__lowercase  (     self  :Dict			):
											torch.manual_seed(0			)
											__lowerCamelCase      :      List[str]         =UNetaDConditionModel(
											    block_out_channels=(32, 64)						,    layers_per_block=2						,    sample_size=32						,    in_channels=4						,    out_channels=4						,    down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')						,    up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')						,    cross_attention_dim=32						,    )
											__lowerCamelCase      :      List[Any]         =DDIMScheduler(
											    beta_start=0.00085						,    beta_end=0.012						,    beta_schedule='''scaled_linear'''						,    num_train_timesteps=1000						,    clip_sample=__lowercase						,    set_alpha_to_one=__lowercase						,    )
											torch.manual_seed(0			)
											__lowerCamelCase      :      Optional[int]         =AutoencoderKL(
											    block_out_channels=[32, 64]						,    in_channels=3						,    out_channels=3						,    down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']						,    up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']						,    latent_channels=4						,    )
											torch.manual_seed(0			)
											__lowerCamelCase      :      int         =CLIPTextConfig(
											    bos_token_id=0						,    eos_token_id=2						,    hidden_size=32						,    intermediate_size=37						,    layer_norm_eps=1e-0_5						,    num_attention_heads=4						,    num_hidden_layers=5						,    pad_token_id=1						,    vocab_size=1000						,    )
											__lowerCamelCase      :      Optional[Any]         =CLIPTextModel(__lowercase			)
											__lowerCamelCase      :      Tuple         =CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''			)

											__lowerCamelCase      :      Optional[int]         ={
											    '''unet''': unet,
											    '''scheduler''': scheduler,
											    '''vae''': vae,
											    '''text_encoder''': text_encoder,
											    '''tokenizer''': tokenizer,
											    '''safety_checker''': None,
											    '''feature_extractor''': None,
											}
											return components




				def 					__lowercase  (     self  :Union[str, Any]						,    __lowercase  :Optional[int]						,    __lowercase  :str=0			):
											__lowerCamelCase      :      List[Any]         =floats_tensor((1, 3, 32, 32)						,    rng=random.Random(__lowercase			)			).to(__lowercase			)
											__lowerCamelCase      :      str         =image / 2 + 0.5
											if str(__lowercase			).startswith('''mps'''			):
																		__lowerCamelCase      :      Union[str, Any]         =torch.manual_seed(__lowercase			)
											else:
																		__lowerCamelCase      :      Any         =torch.Generator(device=__lowercase			).manual_seed(__lowercase			)
											__lowerCamelCase      :      Dict         ={
											    '''prompt''': '''An astronaut riding an elephant''',
											    '''source_prompt''': '''An astronaut riding a horse''',
											    '''image''': image,
											    '''generator''': generator,
											    '''num_inference_steps''': 2,
											    '''eta''': 0.1,
											    '''strength''': 0.8,
											    '''guidance_scale''': 3,
											    '''source_guidance_scale''': 1,
											    '''output_type''': '''numpy''',
											}
											return inputs




				def 					__lowercase  (     self  :Optional[int]			):
											__lowerCamelCase      :      int         ='''cpu'''  # ensure determinism for the device-dependent torch.Generator

											__lowerCamelCase      :      Tuple         =self.get_dummy_components()
											__lowerCamelCase      :      List[str]         =CycleDiffusionPipeline(**__lowercase			)
											__lowerCamelCase      :      Tuple         =pipe.to(__lowercase			)
											pipe.set_progress_bar_config(disable=__lowercase			)

											__lowerCamelCase      :      List[Any]         =self.get_dummy_inputs(__lowercase			)
											__lowerCamelCase      :      int         =pipe(**__lowercase			)
											__lowerCamelCase      :      Dict         =output.images

											__lowerCamelCase      :      Union[str, Any]         =images[0, -3:, -3:, -1]

											assert images.shape == (1, 32, 32, 3)
											__lowerCamelCase      :      Optional[Any]         =np.array([0.4459, 0.4943, 0.4544, 0.6643, 0.5474, 0.4327, 0.5701, 0.5959, 0.5179]			)

											assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2




				@unittest.skipIf(torch_device != '''cuda'''						,    '''This test requires a GPU'''			)
				def 					__lowercase  (     self  :str			):
											__lowerCamelCase      :      str         =self.get_dummy_components()
											for name, module in components.items():
																		if hasattr(__lowercase						,    '''half'''			):
																									__lowerCamelCase      :      Union[str, Any]         =module.half()
											__lowerCamelCase      :      int         =CycleDiffusionPipeline(**__lowercase			)
											__lowerCamelCase      :      List[str]         =pipe.to(__lowercase			)
											pipe.set_progress_bar_config(disable=__lowercase			)

											__lowerCamelCase      :      Optional[int]         =self.get_dummy_inputs(__lowercase			)
											__lowerCamelCase      :      Dict         =pipe(**__lowercase			)
											__lowerCamelCase      :      List[str]         =output.images

											__lowerCamelCase      :      Dict         =images[0, -3:, -3:, -1]

											assert images.shape == (1, 32, 32, 3)
											__lowerCamelCase      :      str         =np.array([0.3506, 0.4543, 0.446, 0.4575, 0.5195, 0.4155, 0.5273, 0.518, 0.4116]			)

											assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2




				@skip_mps
				def 					__lowercase  (     self  :Optional[Any]			):
											return super().test_save_load_local()




				@unittest.skip('''non-deterministic pipeline'''			)
				def 					__lowercase  (     self  :Dict			):
											return super().test_inference_batch_single_identical()




				@skip_mps
				def 					__lowercase  (     self  :Optional[Any]			):
											return super().test_dict_tuple_outputs_equivalent()




				@skip_mps
				def 					__lowercase  (     self  :str			):
											return super().test_save_load_optional_components()




				@skip_mps
				def 					__lowercase  (     self  :Dict			):
											return super().test_attention_slicing_forward_pass()

@slow
@require_torch_gpu
class 		SCREAMING_SNAKE_CASE_							(    unittest.TestCase   ):
				"""simple docstring"""




				def 					__lowercase  (     self  :Tuple			):
											# clean up the VRAM after each test
											super().tearDown()
											gc.collect()
											torch.cuda.empty_cache()




				def 					__lowercase  (     self  :Dict			):
											__lowerCamelCase      :      Dict         =load_image(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
											    '''/cycle-diffusion/black_colored_car.png'''			)
											__lowerCamelCase      :      Union[str, Any]         =load_numpy(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/cycle-diffusion/blue_colored_car_fp16.npy'''			)
											__lowerCamelCase      :      Any         =init_image.resize((512, 512)			)

											__lowerCamelCase      :      Optional[Any]         ='''CompVis/stable-diffusion-v1-4'''
											__lowerCamelCase      :      Optional[Any]         =DDIMScheduler.from_pretrained(__lowercase						,    subfolder='''scheduler'''			)
											__lowerCamelCase      :      Optional[Any]         =CycleDiffusionPipeline.from_pretrained(
											    __lowercase						,    scheduler=__lowercase						,    safety_checker=__lowercase						,    torch_dtype=torch.floataa						,    revision='''fp16'''			)

											pipe.to(__lowercase			)
											pipe.set_progress_bar_config(disable=__lowercase			)
											pipe.enable_attention_slicing()

											__lowerCamelCase      :      Dict         ='''A black colored car'''
											__lowerCamelCase      :      Union[str, Any]         ='''A blue colored car'''

											__lowerCamelCase      :      Dict         =torch.manual_seed(0			)
											__lowerCamelCase      :      Tuple         =pipe(
											    prompt=__lowercase						,    source_prompt=__lowercase						,    image=__lowercase						,    num_inference_steps=100						,    eta=0.1						,    strength=0.85						,    guidance_scale=3						,    source_guidance_scale=1						,    generator=__lowercase						,    output_type='''np'''						,    )
											__lowerCamelCase      :      Tuple         =output.images

											# the values aren't exactly equal, but the images look the same visually
											assert np.abs(image - expected_image			).max() < 5e-1




				def 					__lowercase  (     self  :Any			):
											__lowerCamelCase      :      Tuple         =load_image(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
											    '''/cycle-diffusion/black_colored_car.png'''			)
											__lowerCamelCase      :      List[Any]         =load_numpy(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/cycle-diffusion/blue_colored_car.npy'''			)
											__lowerCamelCase      :      Optional[Any]         =init_image.resize((512, 512)			)

											__lowerCamelCase      :      Any         ='''CompVis/stable-diffusion-v1-4'''
											__lowerCamelCase      :      List[Any]         =DDIMScheduler.from_pretrained(__lowercase						,    subfolder='''scheduler'''			)
											__lowerCamelCase      :      str         =CycleDiffusionPipeline.from_pretrained(__lowercase						,    scheduler=__lowercase						,    safety_checker=__lowercase			)

											pipe.to(__lowercase			)
											pipe.set_progress_bar_config(disable=__lowercase			)
											pipe.enable_attention_slicing()

											__lowerCamelCase      :      Any         ='''A black colored car'''
											__lowerCamelCase      :      int         ='''A blue colored car'''

											__lowerCamelCase      :      Tuple         =torch.manual_seed(0			)
											__lowerCamelCase      :      Union[str, Any]         =pipe(
											    prompt=__lowercase						,    source_prompt=__lowercase						,    image=__lowercase						,    num_inference_steps=100						,    eta=0.1						,    strength=0.85						,    guidance_scale=3						,    source_guidance_scale=1						,    generator=__lowercase						,    output_type='''np'''						,    )
											__lowerCamelCase      :      Dict         =output.images

											assert np.abs(image - expected_image			).max() < 2e-2




