

'''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 		__SCREAMING_SNAKE_CASE       ( lowercase__	,       lowercase__	,       unittest.TestCase			):
				lowerCamelCase_							=						IFInpaintingSuperResolutionPipeline
				lowerCamelCase_							=						TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'width', 'height'}
				lowerCamelCase_							=						TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'original_image'}			)
				lowerCamelCase_							=						PipelineTesterMixin.required_optional_params - {'latents'}







				def    lowerCamelCase_  (					self    :		Union[str, Any]      ):
										'''simple docstring'''
										return self._get_superresolution_dummy_components()







				def    lowerCamelCase_  (					self    :		List[str]		,				UpperCAmelCase__    :		int		,				UpperCAmelCase__    :		Tuple=0      ):
										'''simple docstring'''
										if str(UpperCAmelCase__      ).startswith('''mps'''      ):
																lowercase   :       Tuple								=torch.manual_seed(UpperCAmelCase__      )
										else:
																lowercase   :       str								=torch.Generator(device=UpperCAmelCase__      ).manual_seed(UpperCAmelCase__      )

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

										lowercase   :       str								={
										    '''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    lowerCamelCase_  (					self    :		Optional[int]      ):
										'''simple docstring'''
										self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3      )







				def    lowerCamelCase_  (					self    :		Optional[int]      ):
										'''simple docstring'''
										self._test_save_load_optional_components()







				@unittest.skipIf(torch_device != '''cuda'''		,				reason='''float16 requires CUDA'''      )
				def    lowerCamelCase_  (					self    :		Optional[int]      ):
										'''simple docstring'''
										super().test_save_load_floataa(expected_max_diff=1E-1      )







				def    lowerCamelCase_  (					self    :		Optional[int]      ):
										'''simple docstring'''
										self._test_attention_slicing_forward_pass(expected_max_diff=1E-2      )







				def    lowerCamelCase_  (					self    :		int      ):
										'''simple docstring'''
										self._test_save_load_local()







				def    lowerCamelCase_  (					self    :		Tuple      ):
										'''simple docstring'''
										self._test_inference_batch_single_identical(
										    expected_max_diff=1E-2		,				)








'''simple docstring'''





# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script dumps information about the environment

import os
import platform
import sys


UpperCamelCase_							=					"""3"""

print("""Python version:""", sys.version)

print("""OS platform:""", platform.platform())
print("""OS architecture:""", platform.machine())

try:
							import torch

							print("""Torch version:""", torch.__version__)
							print("""Cuda available:""", torch.cuda.is_available())
							print("""Cuda version:""", torch.version.cuda)
							print("""CuDNN version:""", torch.backends.cudnn.version())
							print("""Number of GPUs available:""", torch.cuda.device_count())
except ImportError:
							print("""Torch version:""", None)

try:
							import transformers

							print("""transformers version:""", transformers.__version__)
except ImportError:
							print("""transformers version:""", None)





