
"""simple docstring"""





import random
import unittest

import torch

from diffusers import IFImgaImgSuperResolutionPipeline
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    _UpperCAmelCase(   A__				,					A__				,					unittest.TestCase     ):
		lowercase__      =				IFImgaImgSuperResolutionPipeline
		lowercase__      =				TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
		lowercase__      =				TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS.union({'original_image'}     )
		lowercase__      =				PipelineTesterMixin.required_optional_params - {"latents"}



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






							'''simple docstring'''
							return self._get_superresolution_dummy_components()



		def 						UpperCAmelCase							( self    ,		__a    ,		__a=0)	->	Optional[int]:






							'''simple docstring'''
							if str(__A).startswith('''mps'''):
												__UpperCamelCase										=  torch.manual_seed(__A)
							else:
												__UpperCamelCase										=  torch.Generator(device=__A).manual_seed(__A)

							__UpperCamelCase										=  floats_tensor((1, 3, 32, 32)    ,		rng=random.Random(__A)).to(__A)
							__UpperCamelCase										=  floats_tensor((1, 3, 16, 16)    ,		rng=random.Random(__A)).to(__A)

							__UpperCamelCase										=  {
							    """prompt""": """A painting of a squirrel eating a burger""",
							    """image""": image,
							    """original_image""": original_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 						UpperCAmelCase							( self)	->	Dict:






							'''simple docstring'''
							self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3)



		def 						UpperCAmelCase							( self)	->	Tuple:






							'''simple docstring'''
							self._test_save_load_optional_components()



		@unittest.skipIf(torch_device != '''cuda'''    ,		reason='''float16 requires CUDA''')
		def 						UpperCAmelCase							( self)	->	Any:






							'''simple docstring'''
							# 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)



		def 						UpperCAmelCase							( self)	->	str:






							'''simple docstring'''
							self._test_attention_slicing_forward_pass(expected_max_diff=1e-2)



		def 						UpperCAmelCase							( self)	->	Dict:






							'''simple docstring'''
							self._test_save_load_local()




		def 						UpperCAmelCase							( self)	->	Union[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


_a														=		logging.get_logger(__name__)

_a														=		{
    """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""",
    # See all BioGPT models at https://huggingface.co/models?filter=biogpt
}






class    _UpperCAmelCase(   lowerCamelCase     ):
		lowercase__      =				'biogpt'



		def __init__( self    ,		__a=4_23_84    ,		__a=10_24    ,		__a=24    ,		__a=16    ,		__a=40_96    ,		__a="gelu"    ,		__a=0.1    ,		__a=0.1    ,		__a=10_24    ,		__a=0.02    ,		__a=1e-12    ,		__a=True    ,		__a=True    ,		__a=0.0    ,		__a=0.0    ,		__a=1    ,		__a=0    ,		__a=2    ,		**__a    ,		)	->	Dict:






							'''simple docstring'''
							_UpperCamelCase										=  vocab_size
							_UpperCamelCase										=  max_position_embeddings
							_UpperCamelCase										=  hidden_size
							_UpperCamelCase										=  num_hidden_layers
							_UpperCamelCase										=  num_attention_heads
							_UpperCamelCase										=  intermediate_size
							_UpperCamelCase										=  hidden_act
							_UpperCamelCase										=  hidden_dropout_prob
							_UpperCamelCase										=  attention_probs_dropout_prob
							_UpperCamelCase										=  initializer_range
							_UpperCamelCase										=  layer_norm_eps
							_UpperCamelCase										=  scale_embedding
							_UpperCamelCase										=  use_cache
							_UpperCamelCase										=  layerdrop
							_UpperCamelCase										=  activation_dropout
							super().__init__(pad_token_id=__a    ,		bos_token_id=__a    ,		eos_token_id=__a    ,		**__a)






