
import random
import unittest

import torch

from diffusers import IFSuperResolutionPipeline
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 						__magic_name__				(  snake_case,			snake_case,			unittest.TestCase      ):
		_lowerCAmelCase						=		IFSuperResolutionPipeline
		_lowerCAmelCase						=		TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
		_lowerCAmelCase						=		TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
		_lowerCAmelCase						=		PipelineTesterMixin.required_optional_params - {"latents"}





		def  _A							(							self      :		int			):
							return self._get_superresolution_dummy_components()





		def  _A							(							self      :		Optional[Any]  ,					lowerCamelCase__      :		Any  ,					lowerCamelCase__      :		Optional[int]=0			):
							if str(lowerCamelCase__			).startswith('''mps'''			):
												lowerCAmelCase						:   Optional[int]							=       torch.manual_seed(lowerCamelCase__			)
							else:
												lowerCAmelCase						:   str							=       torch.Generator(device=lowerCamelCase__			).manual_seed(lowerCamelCase__			)

							lowerCAmelCase						:   Union[str, Any]							=       floats_tensor((1, 3, 3_2, 3_2)  ,					rng=random.Random(lowerCamelCase__			)			).to(lowerCamelCase__			)

							lowerCAmelCase						:   Union[str, Any]							=       {
							    '''prompt''': '''A painting of a squirrel eating a burger''',
							    '''image''': 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      :		Dict			):
							self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3			)





		def  _A							(							self      :		List[str]			):
							self._test_save_load_optional_components()





		@unittest.skipIf(torch_device != '''cuda'''  ,					reason='''float16 requires CUDA'''			)
		def  _A							(							self      :		Tuple			):
							# 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  _A							(							self      :		Optional[int]			):
							self._test_attention_slicing_forward_pass(expected_max_diff=1E-2			)





		def  _A							(							self      :		List[str]			):
							self._test_save_load_local()





		def  _A							(							self      :		Dict			):
							self._test_inference_batch_single_identical(
							    expected_max_diff=1E-2  ,					)


def       UpperCAmelCase__							(    __magic_name__  :       Union[str, Any]							,					__magic_name__  :       int					):


					'''simple docstring'''

					sequence.append(__magic_name__					)

					lowerCAmelCase						:   Tuple							=       0
					while sequence[index] != target:
										index += 1

					sequence.pop()

					if index == len(__magic_name__					):
										return None

					return index


if __name__ == "__main__":
		__SCREAMING_SNAKE_CASE     :				Dict             =       input('Enter numbers separated by comma:\n').strip()
		__SCREAMING_SNAKE_CASE     :				int             =       [int(item) for item in user_input.split(',')]

		__SCREAMING_SNAKE_CASE     :				str             =       input('Enter a single number to be found in the list:\n')
		__SCREAMING_SNAKE_CASE     :				Tuple             =       int(target_input)
		__SCREAMING_SNAKE_CASE     :				Union[str, Any]             =       sentinel_linear_search(sequence, target)
		if result is not None:
				print(f"""{target} found at positions: {result}""")
		else:
				print('Not found')
