




"""simple docstring"""

import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
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     lowercase (      __UpperCAmelCase       ,		__UpperCAmelCase       ,		unittest.TestCase):
				__lowerCAmelCase      :      Dict					    =				IFImgaImgPipeline
				__lowerCAmelCase      :      Tuple					    =				TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""width""", """height"""}
				__lowerCAmelCase      :      str					    =				TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
				__lowerCAmelCase      :      int					    =				PipelineTesterMixin.required_optional_params - {"""latents"""}







				def    a_					(							self				:   List[str]    ):



					"""simple docstring"""

					return self._get_dummy_components()







				def    a_					(							self				:   Optional[int] ,       _lowerCamelCase				:   Tuple ,       _lowerCamelCase				:   Optional[Any]=0    ):



					"""simple docstring"""

					if str(_lowerCamelCase    ).startswith('''mps'''    ):
						A_					:			List[Any]						=						torch.manual_seed(_lowerCamelCase    )
					else:
						A_					:			List[str]						=						torch.Generator(device=_lowerCamelCase    ).manual_seed(_lowerCamelCase    )

					A_					:			List[str]						=						floats_tensor((1, 3, 32, 32) ,       rng=random.Random(_lowerCamelCase    )    ).to(_lowerCamelCase    )

					A_					:			Any						=						{
					    '''prompt''': '''A painting of a squirrel eating a burger''',
					    '''image''': image,
					    '''generator''': generator,
					    '''num_inference_steps''': 2,
					    '''output_type''': '''numpy''',
					}

					return inputs







				def    a_					(							self				:   List[str]    ):



					"""simple docstring"""

					self._test_save_load_optional_components()







				@unittest.skipIf(
				    torch_device != '''cuda''' or not is_xformers_available() ,       reason='''XFormers attention is only available with CUDA and `xformers` installed''' ,       )
				def    a_					(							self				:   List[str]    ):



					"""simple docstring"""

					self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3    )







				@unittest.skipIf(torch_device != '''cuda''' ,       reason='''float16 requires CUDA'''    )
				def    a_					(							self				:   Union[str, Any]    ):



					"""simple docstring"""

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







				@unittest.skipIf(torch_device != '''cuda''' ,       reason='''float16 requires CUDA'''    )
				def    a_					(							self				:   List[str]    ):



					"""simple docstring"""

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







				def    a_					(							self				:   Union[str, Any]    ):



					"""simple docstring"""

					self._test_attention_slicing_forward_pass(expected_max_diff=1E-2    )







				def    a_					(							self				:   Tuple    ):



					"""simple docstring"""

					self._test_save_load_local()







				def    a_					(							self				:   Optional[Any]    ):



					"""simple docstring"""

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











"""simple docstring"""

from .chunk_utils import chunk_layer
from .data_transforms import make_atomaa_masks
from .feats import atomaa_to_atomaa, frames_and_literature_positions_to_atomaa_pos, torsion_angles_to_frames
from .loss import compute_predicted_aligned_error, compute_tm
from .protein import Protein as OFProtein
from .protein import to_pdb
from .rigid_utils import Rigid, Rotation
from .tensor_utils import dict_multimap, flatten_final_dims, permute_final_dims





