



'''simple docstring'''



import unittest

from transformers import is_vision_available
from transformers.pipelines import pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
		from PIL import Image
else:





		class _UpperCamelCase		:





						'''simple docstring'''





						@staticmethod
						def 				__lowerCamelCase     (							*_lowerCAmelCase  :  Any  ,       **_lowerCAmelCase  :  Tuple):







													'''simple docstring'''

													pass





@is_pipeline_test
@require_vision
class _UpperCamelCase		(     unittest.TestCase		):





				'''simple docstring'''





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







											'''simple docstring'''

											__lowercase       	=pipeline(
											    model='hf-internal-testing/tiny-random-clip-zero-shot-image-classification'  ,       )
											__lowercase       	=Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
											__lowercase       	=image_classifier(_lowerCAmelCase  ,       candidate_labels=['a', 'b', 'c'])

											# The floating scores are so close, we enter floating error approximation and the order is not guaranteed across
											# python and torch versions.
											self.assertIn(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        [{'score': 0.333, 'label': 'a'}, {'score': 0.333, 'label': 'b'}, {'score': 0.333, 'label': 'c'}],
											        [{'score': 0.333, 'label': 'a'}, {'score': 0.333, 'label': 'c'}, {'score': 0.333, 'label': 'b'}],
											    ]  ,       )

											__lowercase       	=image_classifier([image] * 5  ,       candidate_labels=['A', 'B', 'C']  ,       batch_size=2)
											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											    ]  ,       )

				@require_tf
				def 				__lowerCamelCase     (							self  :  Optional[int]):







											'''simple docstring'''

											__lowercase       	=pipeline(
											    model='hf-internal-testing/tiny-random-clip-zero-shot-image-classification'  ,       framework='tf')
											__lowercase       	=Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
											__lowercase       	=image_classifier(_lowerCAmelCase  ,       candidate_labels=['a', 'b', 'c'])

											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [{'score': 0.333, 'label': 'a'}, {'score': 0.333, 'label': 'b'}, {'score': 0.333, 'label': 'c'}]  ,       )

											__lowercase       	=image_classifier([image] * 5  ,       candidate_labels=['A', 'B', 'C']  ,       batch_size=2)
											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											        [
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											            {'score': 0.333, 'label': ANY(_lowerCAmelCase)},
											        ],
											    ]  ,       )

				@slow
				@require_torch
				def 				__lowerCamelCase     (							self  :  List[str]):







											'''simple docstring'''

											__lowercase       	=pipeline(
											    task='zero-shot-image-classification'  ,       model='openai/clip-vit-base-patch32'  ,       )
											# This is an image of 2 cats with remotes and no planes
											__lowercase       	=Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
											__lowercase       	=image_classifier(_lowerCAmelCase  ,       candidate_labels=['cat', 'plane', 'remote'])

											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        {'score': 0.511, 'label': 'remote'},
											        {'score': 0.485, 'label': 'cat'},
											        {'score': 0.004, 'label': 'plane'},
											    ]  ,       )

											__lowercase       	=image_classifier([image] * 5  ,       candidate_labels=['cat', 'plane', 'remote']  ,       batch_size=2)
											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        [
											            {'score': 0.511, 'label': 'remote'},
											            {'score': 0.485, 'label': 'cat'},
											            {'score': 0.004, 'label': 'plane'},
											        ],
											    ]
											    * 5  ,       )

				@slow
				@require_tf
				def 				__lowerCamelCase     (							self  :  str):







											'''simple docstring'''

											__lowercase       	=pipeline(
											    task='zero-shot-image-classification'  ,       model='openai/clip-vit-base-patch32'  ,       framework='tf')
											# This is an image of 2 cats with remotes and no planes
											__lowercase       	=Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
											__lowercase       	=image_classifier(_lowerCAmelCase  ,       candidate_labels=['cat', 'plane', 'remote'])
											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        {'score': 0.511, 'label': 'remote'},
											        {'score': 0.485, 'label': 'cat'},
											        {'score': 0.004, 'label': 'plane'},
											    ]  ,       )

											__lowercase       	=image_classifier([image] * 5  ,       candidate_labels=['cat', 'plane', 'remote']  ,       batch_size=2)
											self.assertEqual(
											    nested_simplify(_lowerCAmelCase)  ,       [
											        [
											            {'score': 0.511, 'label': 'remote'},
											            {'score': 0.485, 'label': 'cat'},
											            {'score': 0.004, 'label': 'plane'},
											        ],
											    ]
											    * 5  ,       )








'''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)}")



