
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 LevitImageProcessor


class 				lowercase					(		unittest.TestCase   ):



		def __init__( self				,      A_				,      A_=7				,      A_=3				,      A_=18				,      A_=30				,      A_=400				,      A_=True				,      A_=None				,      A_=True				,      A_=None				,      A_=True				,      A_=[0.5, 0.5, 0.5]				,      A_=[0.5, 0.5, 0.5]				,      )  ->					str:
				"""simple docstring"""
				UpperCamelCase		=     size if size is not None else {'shortest_edge': 18}
				UpperCamelCase		=     crop_size if crop_size is not None else {'height': 18, 'width': 18}
				UpperCamelCase		=     parent
				UpperCamelCase		=     batch_size
				UpperCamelCase		=     num_channels
				UpperCamelCase		=     image_size
				UpperCamelCase		=     min_resolution
				UpperCamelCase		=     max_resolution
				UpperCamelCase		=     do_resize
				UpperCamelCase		=     size
				UpperCamelCase		=     do_center_crop
				UpperCamelCase		=     crop_size
				UpperCamelCase		=     do_normalize
				UpperCamelCase		=     image_mean
				UpperCamelCase		=     image_std



		def __UpperCamelCase ( self       )  ->					str:
				"""simple docstring"""
				return {
				    "image_mean": self.image_mean,
				    "image_std": self.image_std,
				    "do_normalize": self.do_normalize,
				    "do_resize": self.do_resize,
				    "do_center_crop": self.do_center_crop,
				    "size": self.size,
				    "crop_size": self.crop_size,
				}






@require_torch
@require_vision
class 				lowercase					(		_SCREAMING_SNAKE_CASE  ,   unittest.TestCase   ):
		__lowercase       :       int	     =				LevitImageProcessor if is_vision_available() else None



		def __UpperCamelCase ( self       )  ->					List[str]:
				"""simple docstring"""
				UpperCamelCase		=     LevitImageProcessingTester(self       )



		@property
		def __UpperCamelCase ( self       )  ->					Optional[Any]:
				"""simple docstring"""
				return self.image_processor_tester.prepare_image_processor_dict()



		def __UpperCamelCase ( self       )  ->					Optional[int]:
				"""simple docstring"""
				UpperCamelCase		=     self.image_processing_class(**self.image_processor_dict       )
				self.assertTrue(hasattr(A_				,      'image_mean'       )       )
				self.assertTrue(hasattr(A_				,      'image_std'       )       )
				self.assertTrue(hasattr(A_				,      'do_normalize'       )       )
				self.assertTrue(hasattr(A_				,      'do_resize'       )       )
				self.assertTrue(hasattr(A_				,      'do_center_crop'       )       )
				self.assertTrue(hasattr(A_				,      'size'       )       )



		def __UpperCamelCase ( self       )  ->					Any:
				"""simple docstring"""
				UpperCamelCase		=     self.image_processing_class.from_dict(self.image_processor_dict       )
				self.assertEqual(image_processor.size				,      {'shortest_edge': 18}       )
				self.assertEqual(image_processor.crop_size				,      {'height': 18, 'width': 18}       )

				UpperCamelCase		=     self.image_processing_class.from_dict(self.image_processor_dict				,      size=42				,      crop_size=84       )
				self.assertEqual(image_processor.size				,      {'shortest_edge': 42}       )
				self.assertEqual(image_processor.crop_size				,      {'height': 84, 'width': 84}       )



		def __UpperCamelCase ( self       )  ->					Union[str, Any]:
				"""simple docstring"""
				pass



		def __UpperCamelCase ( self       )  ->					Optional[int]:
				"""simple docstring"""
				# Initialize image_processing
				UpperCamelCase		=     self.image_processing_class(**self.image_processor_dict       )
				# create random PIL images
				UpperCamelCase		=     prepare_image_inputs(self.image_processor_tester				,      equal_resolution=A_       )
				for image in image_inputs:
						self.assertIsInstance(A_				,      Image.Image       )

				# Test not batched input
				UpperCamelCase		=     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
				UpperCamelCase		=     image_processing(A_				,      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 __UpperCamelCase ( self       )  ->					Tuple:
				"""simple docstring"""
				# Initialize image_processing
				UpperCamelCase		=     self.image_processing_class(**self.image_processor_dict       )
				# create random numpy tensors
				UpperCamelCase		=     prepare_image_inputs(self.image_processor_tester				,      equal_resolution=A_				,      numpify=A_       )
				for image in image_inputs:
						self.assertIsInstance(A_				,      np.ndarray       )

				# Test not batched input
				UpperCamelCase		=     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
				UpperCamelCase		=     image_processing(A_				,      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 __UpperCamelCase ( self       )  ->					List[Any]:
				"""simple docstring"""
				# Initialize image_processing
				UpperCamelCase		=     self.image_processing_class(**self.image_processor_dict       )
				# create random PyTorch tensors
				UpperCamelCase		=     prepare_image_inputs(self.image_processor_tester				,      equal_resolution=A_				,      torchify=A_       )
				for image in image_inputs:
						self.assertIsInstance(A_				,      torch.Tensor       )

				# Test not batched input
				UpperCamelCase		=     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
				UpperCamelCase		=     image_processing(A_				,      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'],
				    )				,      )


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


def       A       (					lowercase )   ->  str:
		'''simple docstring'''

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

		UpperCamelCase		=     precision
		UpperCamelCase		=     ceil(precision / 14 )
		UpperCamelCase		=     426_880 * Decimal(10_005 ).sqrt()
		UpperCamelCase		=     1
		UpperCamelCase		=     13_591_409
		UpperCamelCase		=     Decimal(lowercase )
		for k in range(1    ,       lowercase ):
				UpperCamelCase		=     factorial(6 * k ) // (factorial(3 * k ) * factorial(lowercase ) ** 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__":
					_UpperCAmelCase					: Dict      =       50
					print(F'''The first {n} digits of pi is: {pi(n)}''')
