


"""simple docstring"""


import math
from decimal import Decimal, getcontext






def   a__			(					__lowercase = 400_0000 )						->						Tuple:






				try:
								_A       	=      int(_UpperCAmelCase )
				except (TypeError, ValueError):
								raise TypeError("Parameter n must be int or castable to int." )
				if n <= 0:
								raise ValueError("Parameter n must be greater than or equal to one." )
				_A       	=      100
				_A       	=      (Decimal(5 ) ** Decimal(0.5 ) + 1) / Decimal(2 )

				_A       	=      (math.floor(math.log(n * (phi + 2)  ,      _UpperCAmelCase ) - 1 ) // 3) * 3 + 2
				_A       	=      Decimal(round(phi ** Decimal(index + 1 ) ) ) / (phi + 2)
				_A       	=      num // 2
				return int(_UpperCAmelCase )


if __name__ == "__main__":
		print(f'''{solution() = }''')





"""simple docstring"""

import unittest

from transformers import (
    MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    PreTrainedTokenizer,
    is_vision_available,
)
from transformers.pipelines import ImageClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
		from PIL import Image
else:

		class 							lowercase   :







						@staticmethod
						def        a_	(				*_lowerCamelCase :       Tuple   ,  **_lowerCamelCase :       str							):



							"""simple docstring"""

							pass

@is_pipeline_test
@require_torch_or_tf
@require_vision
class 							lowercase   (     unittest.TestCase):
				__lowerCAmelCase     :     str								= MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
				__lowerCAmelCase     :     Union[str, Any]								= TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING







				def        a_	(				self :       Tuple   ,  _lowerCamelCase :       Any   ,  _lowerCamelCase :       str   ,  _lowerCamelCase :       Optional[Any]							):



					"""simple docstring"""

					A_	:					List[str]						 =		ImageClassificationPipeline(model=_lowerCamelCase   ,  image_processor=_lowerCamelCase   ,  top_k=2							)
					A_	:					Tuple						 =		[
					    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							),
					    '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					]
					return image_classifier, examples







				def        a_	(				self :       Optional[Any]   ,  _lowerCamelCase :       Optional[int]   ,  _lowerCamelCase :       Optional[Any]							):



					"""simple docstring"""

					A_	:					int						 =		image_classifier('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							)

					self.assertEqual(
					    _lowerCamelCase   ,  [
					        {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					    ]   ,  )

					import datasets

					A_	:					Optional[Any]						 =		datasets.load_dataset('''hf-internal-testing/fixtures_image_utils'''   ,  '''image'''   ,  split='''test'''							)

					# Accepts URL + PIL.Image + lists
					A_	:					Union[str, Any]						 =		image_classifier(
					    [
					        Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							),
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        # RGBA
					        dataset[0]['''file'''],
					        # LA
					        dataset[1]['''file'''],
					        # L
					        dataset[2]['''file'''],
					    ]							)
					self.assertEqual(
					    _lowerCamelCase   ,  [
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					    ]   ,  )







				@require_torch
				def        a_	(				self :       Dict							):



					"""simple docstring"""

					A_	:					Optional[int]						 =		'''hf-internal-testing/tiny-random-vit'''
					A_	:					Tuple						 =		pipeline('''image-classification'''   ,  model=_lowerCamelCase							)

					A_	:					Optional[int]						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]   ,  )

					A_	:					str						 =		image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]   ,  top_k=2   ,  )
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					    ]   ,  )







				@require_tf
				def        a_	(				self :       Tuple							):



					"""simple docstring"""

					A_	:					List[str]						 =		'''hf-internal-testing/tiny-random-vit'''
					A_	:					Optional[int]						 =		pipeline('''image-classification'''   ,  model=_lowerCamelCase   ,  framework='''tf'''							)

					A_	:					Tuple						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]   ,  )

					A_	:					Optional[Any]						 =		image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]   ,  top_k=2   ,  )
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					    ]   ,  )







				def        a_	(				self :       Dict							):



					"""simple docstring"""

					A_	:					Any						 =		PreTrainedTokenizer()

					# Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
					A_	:					List[Any]						 =		pipeline(
					    '''image-classification'''   ,  model='''hf-internal-testing/tiny-random-vit'''   ,  tokenizer=_lowerCamelCase							)

					self.assertIs(image_classifier.tokenizer   ,  _lowerCamelCase							)







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



					"""simple docstring"""

					A_	:					List[Any]						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-conv'''							)
					A_	:					Optional[Any]						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.4385, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.321, '''label''': '''tiger cat'''},
					        {'''score''': 0.0502, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0137, '''label''': '''crib, cot'''},
					        {'''score''': 0.007, '''label''': '''radiator'''},
					    ]   ,  )

					A_	:					Dict						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-fourier'''							)
					A_	:					str						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.5658, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.1309, '''label''': '''tiger cat'''},
					        {'''score''': 0.0722, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0707, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0082, '''label''': '''computer keyboard, keypad'''},
					    ]   ,  )

					A_	:					Optional[int]						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-learned'''							)
					A_	:					int						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.3022, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.2362, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.1856, '''label''': '''tiger cat'''},
					        {'''score''': 0.0324, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0096, '''label''': '''quilt, comforter, comfort, puff'''},
					    ]   ,  )





