'''simple docstring'''




from functools import lru_cache





@lru_cache
def 	_UpperCAmelCase       (				_UpperCamelCase       :      Optional[Any]  )      -> int:





    if not isinstance(__lowerCAmelCase,  __lowerCAmelCase  ):
        raise TypeError('''k must be an integer.'''  )
    if k < 0:
        raise ValueError('''k integer must be greater or equal to zero.'''  )
    if k == 0:
        return 0
    elif k == 1:
        return 1
    else:
        return fibonacci(k - 1  ) + fibonacci(k - 2  )





def 	_UpperCAmelCase       (				_UpperCamelCase       :      Dict,  _UpperCamelCase       :      Any  )      -> int:
    A_      =  len(__lowerCAmelCase  )
    # Find m such that F_m >= n where F_i is the i_th fibonacci number.
    A_      =  0
    while True:
        if fibonacci(__lowerCAmelCase  ) >= len_list:
            A_      =  i
            break
        i += 1
    A_      =  0
    while fibb_k > 0:
        A_      =  min(
            offset + fibonacci(fibb_k - 1  ),  len_list - 1  )  # Prevent out of range
        A_      =  arr[index_k]
        if item_k_1 == val:
            return index_k
        elif val < item_k_1:
            fibb_k -= 1
        elif val > item_k_1:
            offset += fibonacci(fibb_k - 1  )
            fibb_k -= 2
    else:
        return -1


if __name__ == "__main__":
  import doctest

  doctest.testmod()







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 EfficientNetImageProcessor







class       __snake_case (  unittest.TestCase ):
 def __init__(	self		, snake_case__		, snake_case__=13		, snake_case__=3		, snake_case__=18		, snake_case__=30		, snake_case__=400		, snake_case__=True		, snake_case__=None		, snake_case__=True		, snake_case__=[0.5, 0.5, 0.5]		, snake_case__=[0.5, 0.5, 0.5]		, )						->				Any:
       '''simple docstring'''





       UpperCAmelCase     :			int     	=size if size is not None else {'''height''': 18, '''width''': 18}
       UpperCAmelCase     :			Tuple     	=parent
       UpperCAmelCase     :			List[str]     	=batch_size
       UpperCAmelCase     :			int     	=num_channels
       UpperCAmelCase     :			List[str]     	=image_size
       UpperCAmelCase     :			str     	=min_resolution
       UpperCAmelCase     :			Optional[int]     	=max_resolution
       UpperCAmelCase     :			Optional[int]     	=do_resize
       UpperCAmelCase     :			int     	=size
       UpperCAmelCase     :			Union[str, Any]     	=do_normalize
       UpperCAmelCase     :			Dict     	=image_mean
       UpperCAmelCase     :			List[Any]     	=image_std






 def 						UpperCAmelCase__							(	self    )						->				int:
       '''simple docstring'''





       return {
           "image_mean": self.image_mean,
           "image_std": self.image_std,
           "do_normalize": self.do_normalize,
           "do_resize": self.do_resize,
           "size": self.size,
       }







@require_torch
@require_vision
class       __snake_case (  lowerCamelCase__       , unittest.TestCase ):
 __lowerCamelCase     : Any 	=   EfficientNetImageProcessor if is_vision_available() else None
 def 						UpperCAmelCase__							(	self    )						->				Tuple:
       '''simple docstring'''





       UpperCAmelCase     :			Dict     	=EfficientNetImageProcessorTester(self    )
 @property
 def 						UpperCAmelCase__							(	self    )						->				int:
       '''simple docstring'''





       return self.image_processor_tester.prepare_image_processor_dict()
 def 						UpperCAmelCase__							(	self    )						->				List[str]:
       '''simple docstring'''





       UpperCAmelCase     :			Tuple     	=self.image_processing_class(**self.image_processor_dict    )
       self.assertTrue(hasattr(snake_case__		, '''image_mean'''    )    )
       self.assertTrue(hasattr(snake_case__		, '''image_std'''    )    )
       self.assertTrue(hasattr(snake_case__		, '''do_normalize'''    )    )
       self.assertTrue(hasattr(snake_case__		, '''do_resize'''    )    )
       self.assertTrue(hasattr(snake_case__		, '''size'''    )    )
 def 						UpperCAmelCase__							(	self    )						->				Tuple:
       '''simple docstring'''





       UpperCAmelCase     :			str     	=self.image_processing_class.from_dict(self.image_processor_dict    )
       self.assertEqual(image_processor.size		, {'''height''': 18, '''width''': 18}    )

       UpperCAmelCase     :			List[str]     	=self.image_processing_class.from_dict(self.image_processor_dict		, size=42    )
       self.assertEqual(image_processor.size		, {'''height''': 42, '''width''': 42}    )
 def 						UpperCAmelCase__							(	self    )						->				Dict:
       '''simple docstring'''





       UpperCAmelCase     :			List[Any]     	=self.image_processing_class(**self.image_processor_dict    )
       # create random PIL images
       UpperCAmelCase     :			Optional[Any]     	=prepare_image_inputs(self.image_processor_tester		, equal_resolution=snake_case__    )
       for image in image_inputs:
             self.assertIsInstance(snake_case__		, Image.Image    )

       # Test not batched input
       UpperCAmelCase     :			int     	=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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )

       # Test batched
       UpperCAmelCase     :			int     	=image_processing(snake_case__		, 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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )
 def 						UpperCAmelCase__							(	self    )						->				Dict:
       '''simple docstring'''





       UpperCAmelCase     :			Tuple     	=self.image_processing_class(**self.image_processor_dict    )
       # create random numpy tensors
       UpperCAmelCase     :			List[str]     	=prepare_image_inputs(self.image_processor_tester		, equal_resolution=snake_case__		, numpify=snake_case__    )
       for image in image_inputs:
             self.assertIsInstance(snake_case__		, np.ndarray    )

       # Test not batched input
       UpperCAmelCase     :			str     	=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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )

       # Test batched
       UpperCAmelCase     :			Union[str, Any]     	=image_processing(snake_case__		, 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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )






 def 						UpperCAmelCase__							(	self    )						->				str:
       '''simple docstring'''





       UpperCAmelCase     :			int     	=self.image_processing_class(**self.image_processor_dict    )
       # create random PyTorch tensors
       UpperCAmelCase     :			int     	=prepare_image_inputs(self.image_processor_tester		, equal_resolution=snake_case__		, torchify=snake_case__    )
       for image in image_inputs:
             self.assertIsInstance(snake_case__		, torch.Tensor    )

       # Test not batched input
       UpperCAmelCase     :			List[Any]     	=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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )

       # Test batched
       UpperCAmelCase     :			List[str]     	=image_processing(snake_case__		, 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.size['''height'''],
               self.image_processor_tester.size['''width'''],
           )		, )
