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 						__snake_case						:





          '''simple docstring'''






          @staticmethod
          def 						_SCREAMING_SNAKE_CASE     (       *_UpperCamelCase  :					int     ,	**_UpperCamelCase  :					int)					->Union[str, Any]:


              """simple docstring"""


              pass




@is_pipeline_test
@require_torch_or_tf
@require_vision
class 						__snake_case						(			unittest.TestCase		):





      '''simple docstring'''






      _snake_case     		=							MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
      _snake_case     		=							TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING



      def 						_SCREAMING_SNAKE_CASE     (       self  :					Tuple     ,	_UpperCamelCase  :					Optional[Any]     ,	_UpperCamelCase  :					Tuple     ,	_UpperCamelCase  :					int)					->str:


          """simple docstring"""


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



      def 						_SCREAMING_SNAKE_CASE     (       self  :					List[str]     ,	_UpperCamelCase  :					str     ,	_UpperCamelCase  :					Any)					->Optional[Any]:


          """simple docstring"""


          _lowerCamelCase  :		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

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

          # Accepts URL + PIL.Image + lists
          _lowerCamelCase  :		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 						_SCREAMING_SNAKE_CASE     (       self  :					Optional[int])					->int:


          """simple docstring"""


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

          _lowerCamelCase  :		Optional[Any]			    =    image_classifier("""http://images.cocodataset.org/val2017/000000039769.jpg""")
          self.assertEqual(
              nested_simplify(_UpperCamelCase     ,	decimals=4)     ,	[{"""label""": """LABEL_1""", """score""": 0.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}]     ,	)

          _lowerCamelCase  :		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.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}],
                  [{"""label""": """LABEL_1""", """score""": 0.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}],
              ]     ,	)



      @require_tf
      def 						_SCREAMING_SNAKE_CASE     (       self  :					str)					->Optional[int]:


          """simple docstring"""


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

          _lowerCamelCase  :		Union[str, Any]			    =    image_classifier("""http://images.cocodataset.org/val2017/000000039769.jpg""")
          self.assertEqual(
              nested_simplify(_UpperCamelCase     ,	decimals=4)     ,	[{"""label""": """LABEL_1""", """score""": 0.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}]     ,	)

          _lowerCamelCase  :		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.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}],
                  [{"""label""": """LABEL_1""", """score""": 0.5_7_4}, {"""label""": """LABEL_0""", """score""": 0.4_2_6}],
              ]     ,	)



      def 						_SCREAMING_SNAKE_CASE     (       self  :					Dict)					->Tuple:


          """simple docstring"""


          _lowerCamelCase  :		Optional[int]			    =    PreTrainedTokenizer()

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

          self.assertIs(image_classifier.tokenizer     ,	_UpperCamelCase)




      @slow
      @require_torch
      def 						_SCREAMING_SNAKE_CASE     (       self  :					List[str])					->List[Any]:


          """simple docstring"""


          _lowerCamelCase  :		Optional[int]			    =    pipeline("""image-classification"""     ,	model="""deepmind/vision-perceiver-conv""")
          _lowerCamelCase  :		int			    =    image_classifier("""http://images.cocodataset.org/val2017/000000039769.jpg""")
          self.assertEqual(
              nested_simplify(_UpperCamelCase     ,	decimals=4)     ,	[
                  {"""score""": 0.4_3_8_5, """label""": """tabby, tabby cat"""},
                  {"""score""": 0.3_2_1, """label""": """tiger cat"""},
                  {"""score""": 0.0_5_0_2, """label""": """Egyptian cat"""},
                  {"""score""": 0.0_1_3_7, """label""": """crib, cot"""},
                  {"""score""": 0.0_0_7, """label""": """radiator"""},
              ]     ,	)

          _lowerCamelCase  :		Dict			    =    pipeline("""image-classification"""     ,	model="""deepmind/vision-perceiver-fourier""")
          _lowerCamelCase  :		str			    =    image_classifier("""http://images.cocodataset.org/val2017/000000039769.jpg""")
          self.assertEqual(
              nested_simplify(_UpperCamelCase     ,	decimals=4)     ,	[
                  {"""score""": 0.5_6_5_8, """label""": """tabby, tabby cat"""},
                  {"""score""": 0.1_3_0_9, """label""": """tiger cat"""},
                  {"""score""": 0.0_7_2_2, """label""": """Egyptian cat"""},
                  {"""score""": 0.0_7_0_7, """label""": """remote control, remote"""},
                  {"""score""": 0.0_0_8_2, """label""": """computer keyboard, keypad"""},
              ]     ,	)

          _lowerCamelCase  :		Dict			    =    pipeline("""image-classification"""     ,	model="""deepmind/vision-perceiver-learned""")
          _lowerCamelCase  :		Dict			    =    image_classifier("""http://images.cocodataset.org/val2017/000000039769.jpg""")
          self.assertEqual(
              nested_simplify(_UpperCamelCase     ,	decimals=4)     ,	[
                  {"""score""": 0.3_0_2_2, """label""": """tabby, tabby cat"""},
                  {"""score""": 0.2_3_6_2, """label""": """Egyptian cat"""},
                  {"""score""": 0.1_8_5_6, """label""": """tiger cat"""},
                  {"""score""": 0.0_3_2_4, """label""": """remote control, remote"""},
                  {"""score""": 0.0_0_9_6, """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)}""")




