






'''simple docstring'''




import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
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_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin







@skip_mps
class    A_	(a_						,					a_						,					unittest.TestCase							):
							"""simple docstring"""




							a__   		=	IFInpaintingSuperResolutionPipeline
							a__   		=	TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
							a__   		=	TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'''original_image'''}							)
							a__   		=	PipelineTesterMixin.required_optional_params - {'''latents'''}

							def 							_A	(		self			:Tuple				)				->  List[str]:


										'''simple docstring'''




										return self._get_superresolution_dummy_components()

							def 							_A	(		self			:Optional[int]       ,							lowerCAmelCase__			:Tuple       ,							lowerCAmelCase__			:List[Any]=0				)				->  List[Any]:


										'''simple docstring'''




										if str(lowerCAmelCase__				).startswith("mps"				):
													snake_case_				:					List[Any]   =       torch.manual_seed(lowerCAmelCase__				)
										else:
													snake_case_				:					Dict   =       torch.Generator(device=lowerCAmelCase__				).manual_seed(lowerCAmelCase__				)

										snake_case_				:					List[str]   =       floats_tensor((1, 3, 16, 16)       ,							rng=random.Random(lowerCAmelCase__				)				).to(lowerCAmelCase__				)
										snake_case_				:					Optional[Any]   =       floats_tensor((1, 3, 32, 32)       ,							rng=random.Random(lowerCAmelCase__				)				).to(lowerCAmelCase__				)
										snake_case_				:					Tuple   =       floats_tensor((1, 3, 32, 32)       ,							rng=random.Random(lowerCAmelCase__				)				).to(lowerCAmelCase__				)

										snake_case_				:					List[Any]   =       {
										    "prompt": "A painting of a squirrel eating a burger",
										    "image": image,
										    "original_image": original_image,
										    "mask_image": mask_image,
										    "generator": generator,
										    "num_inference_steps": 2,
										    "output_type": "numpy",
										}

										return inputs

							@unittest.skipIf(
							    torch_device != "cuda" or not is_xformers_available()       ,							reason="XFormers attention is only available with CUDA and `xformers` installed"       ,							)
							def 							_A	(		self			:Union[str, Any]				)				->  int:


										'''simple docstring'''




										self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3				)

							def 							_A	(		self			:List[Any]				)				->  Dict:


										'''simple docstring'''




										self._test_save_load_optional_components()

							@unittest.skipIf(torch_device != "cuda"       ,							reason="float16 requires CUDA"				)
							def 							_A	(		self			:List[Any]				)				->  Optional[Any]:


										'''simple docstring'''




										super().test_save_load_floataa(expected_max_diff=1E-1				)

							def 							_A	(		self			:Tuple				)				->  List[Any]:


										'''simple docstring'''




										self._test_attention_slicing_forward_pass(expected_max_diff=1E-2				)

							def 							_A	(		self			:Any				)				->  Dict:


										'''simple docstring'''




										self._test_save_load_local()






							def 							_A	(		self			:List[str]				)				->  Any:


										'''simple docstring'''




										self._test_inference_batch_single_identical(
										    expected_max_diff=1E-2       ,							)












'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCamelCase   :					List[str]   							=					logging.get_logger(__name__)

__lowerCamelCase   :					int   							=					{
    '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}







class    A_	(a_							):
							"""simple docstring"""




							a__   		=	'''cvt'''

							def __init__(		self			:List[Any]       ,							lowerCAmelCase__			:Optional[int]=3       ,							lowerCAmelCase__			:Any=[7, 3, 3]       ,							lowerCAmelCase__			:Dict=[4, 2, 2]       ,							lowerCAmelCase__			:Union[str, Any]=[2, 1, 1]       ,							lowerCAmelCase__			:Any=[64, 192, 384]       ,							lowerCAmelCase__			:List[str]=[1, 3, 6]       ,							lowerCAmelCase__			:str=[1, 2, 10]       ,							lowerCAmelCase__			:Any=[4.0, 4.0, 4.0]       ,							lowerCAmelCase__			:int=[0.0, 0.0, 0.0]       ,							lowerCAmelCase__			:Optional[Any]=[0.0, 0.0, 0.0]       ,							lowerCAmelCase__			:Dict=[0.0, 0.0, 0.1]       ,							lowerCAmelCase__			:List[Any]=[True, True, True]       ,							lowerCAmelCase__			:List[Any]=[False, False, True]       ,							lowerCAmelCase__			:Dict=["dw_bn", "dw_bn", "dw_bn"]       ,							lowerCAmelCase__			:Any=[3, 3, 3]       ,							lowerCAmelCase__			:Tuple=[1, 1, 1]       ,							lowerCAmelCase__			:Optional[int]=[2, 2, 2]       ,							lowerCAmelCase__			:Union[str, Any]=[1, 1, 1]       ,							lowerCAmelCase__			:Any=[1, 1, 1]       ,							lowerCAmelCase__			:List[str]=0.0_2       ,							lowerCAmelCase__			:Dict=1E-1_2       ,							**lowerCAmelCase__			:Optional[Any]       ,							)				->  str:


										'''simple docstring'''




										super().__init__(**lowerCAmelCase__				)
										snake_case_				:					int   =       num_channels
										snake_case_				:					int   =       patch_sizes
										snake_case_				:					Optional[Any]   =       patch_stride
										snake_case_				:					Dict   =       patch_padding
										snake_case_				:					Tuple   =       embed_dim
										snake_case_				:					Optional[int]   =       num_heads
										snake_case_				:					Union[str, Any]   =       depth
										snake_case_				:					Optional[int]   =       mlp_ratio
										snake_case_				:					Tuple   =       attention_drop_rate
										snake_case_				:					str   =       drop_rate
										snake_case_				:					Tuple   =       drop_path_rate
										snake_case_				:					Any   =       qkv_bias
										snake_case_				:					Union[str, Any]   =       cls_token
										snake_case_				:					int   =       qkv_projection_method
										snake_case_				:					Any   =       kernel_qkv
										snake_case_				:					Union[str, Any]   =       padding_kv
										snake_case_				:					str   =       stride_kv
										snake_case_				:					Dict   =       padding_q
										snake_case_				:					Tuple   =       stride_q
										snake_case_				:					Any   =       initializer_range
										snake_case_				:					Any   =       layer_norm_eps




