"""simple docstring"""







import random
import unittest

import torch

from diffusers import IFInpaintingPipeline
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 		UpperCamelCase      (   lowercase				,     lowercase				,     unittest.TestCase						):
				UpperCAmelCase    :				Tuple   =		IFInpaintingPipeline
				UpperCAmelCase    :				Optional[Any]   =		TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {"""width""", """height"""}
				UpperCAmelCase    :				Dict   =		TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
				UpperCAmelCase    :				Dict   =		PipelineTesterMixin.required_optional_params - {"""latents"""}



				def  _lowercase					(self    :				List[str])   ->     Optional[Any]:
					return self._get_dummy_components()



				def  _lowercase					(self    :				Tuple     ,  _A    :				Union[str, Any]     ,  _A    :				int=0)   ->     Dict:
					if str(_A).startswith('mps'):
						__snake_case      :							Any						=			torch.manual_seed(_A)
					else:
						__snake_case      :							Any						=			torch.Generator(device=_A).manual_seed(_A)

					__snake_case      :							Optional[Any]						=			floats_tensor((1, 3, 32, 32)     ,  rng=random.Random(_A)).to(_A)
					__snake_case      :							str						=			floats_tensor((1, 3, 32, 32)     ,  rng=random.Random(_A)).to(_A)

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



				def  _lowercase					(self    :				Any)   ->     Optional[Any]:
					self._test_save_load_optional_components()



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



				def  _lowercase					(self    :				str)   ->     int:
					self._test_save_load_local()






				def  _lowercase					(self    :				List[Any])   ->     List[str]:
					self._test_inference_batch_single_identical(
					    expected_max_diff=1E-2     ,  )

"""simple docstring"""







from decimal import Decimal, getcontext
from math import ceil, factorial
def   __UpperCAmelCase    (   UpperCAmelCase_   :    int  )							->      str:

	'''simple docstring'''





	if not isinstance(UpperCAmelCase_      ,							UpperCAmelCase_  ):
		raise TypeError('Undefined for non-integers'  )
	elif precision < 1:
		raise ValueError('Undefined for non-natural numbers'  )

	__snake_case      :							Any						=			precision
	__snake_case      :							Optional[int]						=			ceil(precision / 14  )
	__snake_case      :							List[Any]						=			42_68_80 * Decimal(1_00_05  ).sqrt()
	__snake_case      :							Optional[Any]						=			1
	__snake_case      :							Union[str, Any]						=			13_59_14_09
	__snake_case      :							int						=			Decimal(UpperCAmelCase_  )
	for k in range(1      ,							UpperCAmelCase_  ):
		__snake_case      :							Union[str, Any]						=			factorial(6 * k  ) // (factorial(3 * k  ) * factorial(UpperCAmelCase_  ) ** 3)
		linear_term += 5_45_14_01_34
		exponential_term *= -26_25_37_41_26_40_76_80_00
		partial_sum += Decimal(multinomial_term * linear_term  ) / exponential_term
	return str(constant_term / partial_sum  )[:-1]


if __name__ == "__main__":
	_a					:					List[Any]=			50
	print(f'''The first {n} digits of pi is: {pi(n)}''')





