


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  UpperCAmelCase_						:
         '''simple docstring'''






         @staticmethod
         def 			_lowercase (  *__SCREAMING_SNAKE_CASE			,       **__SCREAMING_SNAKE_CASE    ):




                """simple docstring"""




                pass



@is_pipeline_test
@require_torch_or_tf
@require_vision
class  UpperCAmelCase_						(				unittest.TestCase):
       '''simple docstring'''
       __UpperCamelCase   :  Optional[Any]				=       MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
       __UpperCamelCase   :  Any				=       TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING






       def 			_lowercase (  self			,       __SCREAMING_SNAKE_CASE			,       __SCREAMING_SNAKE_CASE			,       __SCREAMING_SNAKE_CASE    ):




              """simple docstring"""




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






       def 			_lowercase (  self			,       __SCREAMING_SNAKE_CASE			,       __SCREAMING_SNAKE_CASE    ):




              """simple docstring"""




              UpperCamelCase     :						Tuple 						=		image_classifier('''./tests/fixtures/tests_samples/COCO/000000039769.png'''    )

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

              import datasets

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

              # Accepts URL + PIL.Image + lists
              UpperCamelCase     :						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(
                  _UpperCamelCase			,       [
                      [
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                      ],
                      [
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                      ],
                      [
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                      ],
                      [
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                      ],
                      [
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                          {'''score''': ANY(_UpperCamelCase    ), '''label''': ANY(_UpperCamelCase    )},
                      ],
                  ]			,       )






       @require_torch
       def 			_lowercase (  self    ):




              """simple docstring"""




              UpperCamelCase     :						Optional[Any] 						=		"""hf-internal-testing/tiny-random-vit"""
              UpperCamelCase     :						int 						=		pipeline('''image-classification'''			,       model=_UpperCamelCase    )

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

              UpperCamelCase     :						Tuple 						=		image_classifier(
                  [
                      '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                      '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                  ]			,       top_k=2			,       )
              self.assertEqual(
                  nested_simplify(_UpperCamelCase			,       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 			_lowercase (  self    ):




              """simple docstring"""




              UpperCamelCase     :						Dict 						=		"""hf-internal-testing/tiny-random-vit"""
              UpperCamelCase     :						Union[str, Any] 						=		pipeline('''image-classification'''			,       model=_UpperCamelCase			,       framework='''tf'''    )

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

              UpperCamelCase     :						Dict 						=		image_classifier(
                  [
                      '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                      '''http://images.cocodataset.org/val2017/000000039769.jpg''',
                  ]			,       top_k=2			,       )
              self.assertEqual(
                  nested_simplify(_UpperCamelCase			,       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 			_lowercase (  self    ):




              """simple docstring"""




              UpperCamelCase     :						Optional[int] 						=		PreTrainedTokenizer()

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

              self.assertIs(image_classifier.tokenizer			,       _UpperCamelCase    )






       @slow
       @require_torch
       def 			_lowercase (  self    ):




              """simple docstring"""




              UpperCamelCase     :						Optional[int] 						=		pipeline('''image-classification'''			,       model='''deepmind/vision-perceiver-conv'''    )
              UpperCamelCase     :						int 						=		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''    )
              self.assertEqual(
                  nested_simplify(_UpperCamelCase			,       decimals=4    )			,       [
                      {'''score''': 0.4_385, '''label''': '''tabby, tabby cat'''},
                      {'''score''': 0.321, '''label''': '''tiger cat'''},
                      {'''score''': 0.0_502, '''label''': '''Egyptian cat'''},
                      {'''score''': 0.0_137, '''label''': '''crib, cot'''},
                      {'''score''': 0.007, '''label''': '''radiator'''},
                  ]			,       )

              UpperCamelCase     :						Dict 						=		pipeline('''image-classification'''			,       model='''deepmind/vision-perceiver-fourier'''    )
              UpperCamelCase     :						str 						=		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''    )
              self.assertEqual(
                  nested_simplify(_UpperCamelCase			,       decimals=4    )			,       [
                      {'''score''': 0.5_658, '''label''': '''tabby, tabby cat'''},
                      {'''score''': 0.1_309, '''label''': '''tiger cat'''},
                      {'''score''': 0.0_722, '''label''': '''Egyptian cat'''},
                      {'''score''': 0.0_707, '''label''': '''remote control, remote'''},
                      {'''score''': 0.0_082, '''label''': '''computer keyboard, keypad'''},
                  ]			,       )

              UpperCamelCase     :						Dict 						=		pipeline('''image-classification'''			,       model='''deepmind/vision-perceiver-learned'''    )
              UpperCamelCase     :						Dict 						=		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''    )
              self.assertEqual(
                  nested_simplify(_UpperCamelCase			,       decimals=4    )			,       [
                      {'''score''': 0.3_022, '''label''': '''tabby, tabby cat'''},
                      {'''score''': 0.2_362, '''label''': '''Egyptian cat'''},
                      {'''score''': 0.1_856, '''label''': '''tiger cat'''},
                      {'''score''': 0.0_324, '''label''': '''remote control, remote'''},
                      {'''score''': 0.0_096, '''label''': '''quilt, comforter, comfort, puff'''},
                  ]			,       )


from __future__ import annotations

import sys







def     A__	(       __A						):







    '''simple docstring'''
    if n < 0:
        raise ValueError("""Negative arguments are not supported"""						)
    return _fib(__A						)[0]







def     A__	(       __A						):







    '''simple docstring'''
    if n == 0:  # (F(0), F(1))
        return (0, 1)

    # F(2n) = F(n)[2F(n+1) − F(n)]
    # F(2n+1) = F(n+1)^2+F(n)^2
    _lowerCamelCase    ,				_lowerCamelCase  :		List[Any]			    =    _fib(n // 2						)
    _lowerCamelCase  :		List[Any]			    =    a * (b * 2 - a)
    _lowerCamelCase  :		Optional[int]			    =    a * a + b * b
    return (d, c + d) if n % 2 else (c, d)


if __name__ == "__main__":
    lowerCAmelCase      :				Union[str, Any]     			=int(sys.argv[1])
    print(F"""fibonacci({n}) is {fibonacci(n)}""")




