



'''simple docstring'''



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import MobileViTImageProcessor





class _UpperCamelCase		(     unittest.TestCase		):





				'''simple docstring'''





				def __init__(							self  :  Tuple  ,       _lowerCAmelCase  :  Dict  ,       _lowerCAmelCase  :  str=7  ,       _lowerCAmelCase  :  Any=3  ,       _lowerCAmelCase  :  List[Any]=1_8  ,       _lowerCAmelCase  :  Any=3_0  ,       _lowerCAmelCase  :  Tuple=4_0_0  ,       _lowerCAmelCase  :  Union[str, Any]=True  ,       _lowerCAmelCase  :  Optional[int]=None  ,       _lowerCAmelCase  :  Optional[Any]=True  ,       _lowerCAmelCase  :  Tuple=None  ,       _lowerCAmelCase  :  str=True  ,       ):







											'''simple docstring'''

											__lowercase       	=size if size is not None else {'shortest_edge': 2_0}
											__lowercase       	=crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}
											__lowercase       	=parent
											__lowercase       	=batch_size
											__lowercase       	=num_channels
											__lowercase       	=image_size
											__lowercase       	=min_resolution
											__lowercase       	=max_resolution
											__lowercase       	=do_resize
											__lowercase       	=size
											__lowercase       	=do_center_crop
											__lowercase       	=crop_size
											__lowercase       	=do_flip_channel_order

				def 				__lowerCamelCase     (							self  :  Optional[Any]):







											'''simple docstring'''

											return {
											    "do_resize": self.do_resize,
											    "size": self.size,
											    "do_center_crop": self.do_center_crop,
											    "crop_size": self.crop_size,
											    "do_flip_channel_order": self.do_flip_channel_order,
											}





@require_torch
@require_vision
class _UpperCamelCase		(     A      ,       unittest.TestCase		):





				'''simple docstring'''





				lowerCAmelCase__					    =    MobileViTImageProcessor if is_vision_available() else None

				def 				__lowerCamelCase     (							self  :  Optional[Any]):







											'''simple docstring'''

											__lowercase       	=MobileViTImageProcessingTester(self)

				@property
				def 				__lowerCamelCase     (							self  :  Optional[Any]):







											'''simple docstring'''

											return self.image_processor_tester.prepare_image_processor_dict()

				def 				__lowerCamelCase     (							self  :  Optional[Any]):







											'''simple docstring'''

											__lowercase       	=self.image_processing_class(**self.image_processor_dict)
											self.assertTrue(hasattr(_lowerCAmelCase  ,       'do_resize'))
											self.assertTrue(hasattr(_lowerCAmelCase  ,       'size'))
											self.assertTrue(hasattr(_lowerCAmelCase  ,       'do_center_crop'))
											self.assertTrue(hasattr(_lowerCAmelCase  ,       'center_crop'))
											self.assertTrue(hasattr(_lowerCAmelCase  ,       'do_flip_channel_order'))

				def 				__lowerCamelCase     (							self  :  Tuple):







											'''simple docstring'''

											__lowercase       	=self.image_processing_class.from_dict(self.image_processor_dict)
											self.assertEqual(image_processor.size  ,       {'shortest_edge': 2_0})
											self.assertEqual(image_processor.crop_size  ,       {'height': 1_8, 'width': 1_8})

											__lowercase       	=self.image_processing_class.from_dict(self.image_processor_dict  ,       size=4_2  ,       crop_size=8_4)
											self.assertEqual(image_processor.size  ,       {'shortest_edge': 4_2})
											self.assertEqual(image_processor.crop_size  ,       {'height': 8_4, 'width': 8_4})

				def 				__lowerCamelCase     (							self  :  Optional[Any]):







											'''simple docstring'''

											pass

				def 				__lowerCamelCase     (							self  :  str):







											'''simple docstring'''

											__lowercase       	=self.image_processing_class(**self.image_processor_dict)
											# create random PIL images
											__lowercase       	=prepare_image_inputs(self.image_processor_tester  ,       equal_resolution=_lowerCAmelCase)
											for image in image_inputs:
																		self.assertIsInstance(_lowerCAmelCase  ,       Image.Image)

											# Test not batched input
											__lowercase       	=image_processing(image_inputs[0]  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        1,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )

											# Test batched
											__lowercase       	=image_processing(_lowerCAmelCase  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )

				def 				__lowerCamelCase     (							self  :  List[Any]):







											'''simple docstring'''

											__lowercase       	=self.image_processing_class(**self.image_processor_dict)
											# create random numpy tensors
											__lowercase       	=prepare_image_inputs(self.image_processor_tester  ,       equal_resolution=_lowerCAmelCase  ,       numpify=_lowerCAmelCase)
											for image in image_inputs:
																		self.assertIsInstance(_lowerCAmelCase  ,       np.ndarray)

											# Test not batched input
											__lowercase       	=image_processing(image_inputs[0]  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        1,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )

											# Test batched
											__lowercase       	=image_processing(_lowerCAmelCase  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )

				def 				__lowerCamelCase     (							self  :  List[str]):







											'''simple docstring'''

											__lowercase       	=self.image_processing_class(**self.image_processor_dict)
											# create random PyTorch tensors
											__lowercase       	=prepare_image_inputs(self.image_processor_tester  ,       equal_resolution=_lowerCAmelCase  ,       torchify=_lowerCAmelCase)
											for image in image_inputs:
																		self.assertIsInstance(_lowerCAmelCase  ,       torch.Tensor)

											# Test not batched input
											__lowercase       	=image_processing(image_inputs[0]  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        1,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )

											# Test batched
											__lowercase       	=image_processing(_lowerCAmelCase  ,       return_tensors='pt').pixel_values
											self.assertEqual(
											    encoded_images.shape  ,       (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.crop_size['height'],
											        self.image_processor_tester.crop_size['width'],
											    )  ,       )








'''simple docstring'''



from decimal import Decimal, getcontext
from math import ceil, factorial



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



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

							__lowercase       	=precision
							__lowercase       	=ceil(precision / 14					)
							__lowercase       	=426_880 * Decimal(10_005					).sqrt()
							__lowercase       	=1
							__lowercase       	=13_591_409
							__lowercase       	=Decimal(_lowerCAmelCase					)
							for k in range(1  ,   _lowerCAmelCase					):
														__lowercase       	=factorial(6 * k					) // (factorial(3 * k					) * factorial(_lowerCAmelCase					) ** 3)
														linear_term += 545_140_134
														exponential_term *= -262_537_412_640_768_000
														partial_sum += Decimal(multinomial_term * linear_term					) / exponential_term
							return str(constant_term / partial_sum					)[:-1]


if __name__ == "__main__":
		lowerCamelCase	 =       50
		print(f"The first {n} digits of pi is: {pi(n)}")



