






"""simple docstring"""




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


if is_torch_available():
 import torch

if is_vision_available():
 from PIL import Image

 from transformers import SwinaSRImageProcessor
 from transformers.image_transforms import get_image_size






class  UpperCamelCase    (			unittest.TestCase   ):


 def __init__(  self	:		Optional[int]							,		UpperCAmelCase__	:		Optional[Any]							,		UpperCAmelCase__	:		Optional[Any]=7							,		UpperCAmelCase__	:		Union[str, Any]=3							,		UpperCAmelCase__	:		Optional[int]=18							,		UpperCAmelCase__	:		Dict=30							,		UpperCAmelCase__	:		Dict=400							,		UpperCAmelCase__	:		Dict=True							,		UpperCAmelCase__	:		List[Any]=1 / 255							,		UpperCAmelCase__	:		List[str]=True							,		UpperCAmelCase__	:		str=8							,		)      -> Dict:
   _a						: Any    =			parent
   _a						: Tuple    =			batch_size
   _a						: Dict    =			num_channels
   _a						: Optional[Any]    =			image_size
   _a						: Any    =			min_resolution
   _a						: Tuple    =			max_resolution
   _a						: List[str]    =			do_rescale
   _a						: Tuple    =			rescale_factor
   _a						: Union[str, Any]    =			do_pad
   _a						: Any    =			pad_size


 def _lowercase			(  self	:		Any							)      -> str:
   return {
       "do_rescale": self.do_rescale,
       "rescale_factor": self.rescale_factor,
       "do_pad": self.do_pad,
       "pad_size": self.pad_size,
   }







 def _lowercase			(  self	:		Dict							,		UpperCAmelCase__	:		List[str]=False							,		UpperCAmelCase__	:		Optional[Any]=False							,		UpperCAmelCase__	:		str=False							)      -> Any:
   assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

   if equal_resolution:
     _a						: Union[str, Any]    =			[]
     for i in range(self.batch_size							):
       image_inputs.append(
           np.random.randint(
               255							,		size=(self.num_channels, self.max_resolution, self.max_resolution)							,		dtype=np.uinta							)							)
   else:
     _a						: int    =			[]
     for i in range(self.batch_size							):
       _a   ,						_a						: Tuple    =			np.random.choice(np.arange(self.min_resolution							,		self.max_resolution							)							,		2							)
       image_inputs.append(np.random.randint(255							,		size=(self.num_channels, width, height)							,		dtype=np.uinta							)							)

   if not numpify and not torchify:
     # PIL expects the channel dimension as last dimension
     _a						: Optional[Any]    =			[Image.fromarray(np.moveaxis(UpperCAmelCase__							,		0							,		-1							)							) for x in image_inputs]

   if torchify:
     _a						: Union[str, Any]    =			[torch.from_numpy(UpperCAmelCase__							) for x in image_inputs]

   return image_inputs







@require_torch
@require_vision
class  UpperCamelCase    (			snake_case_	,  unittest.TestCase   ):
 UpperCamelCase      : int    =      SwinaSRImageProcessor if is_vision_available() else None


 def _lowercase			(  self	:		List[Any]							)      -> Any:
   _a						: str    =			SwinaSRImageProcessingTester(self							)


 @property
 def _lowercase			(  self	:		Optional[int]							)      -> Optional[Any]:
   return self.image_processor_tester.prepare_image_processor_dict()


 def _lowercase			(  self	:		List[str]							)      -> Any:
   _a						: List[Any]    =			self.image_processing_class(**self.image_processor_dict							)
   self.assertTrue(hasattr(UpperCAmelCase__							,		"""do_rescale"""							)							)
   self.assertTrue(hasattr(UpperCAmelCase__							,		"""rescale_factor"""							)							)
   self.assertTrue(hasattr(UpperCAmelCase__							,		"""do_pad"""							)							)
   self.assertTrue(hasattr(UpperCAmelCase__							,		"""pad_size"""							)							)


 def _lowercase			(  self	:		Any							)      -> Tuple:
   pass


 def _lowercase			(  self	:		int							,		UpperCAmelCase__	:		Optional[Any]							)      -> Tuple:
   _a   ,						_a						: List[Any]    =			get_image_size(UpperCAmelCase__							)
   _a						: Optional[Any]    =			self.image_processor_tester.pad_size

   _a						: Union[str, Any]    =			(old_height // size + 1) * size - old_height
   _a						: List[str]    =			(old_width // size + 1) * size - old_width
   return old_height + pad_height, old_width + pad_width


 def _lowercase			(  self	:		str							)      -> List[Any]:
   # Initialize image_processor
   _a						: Tuple    =			self.image_processing_class(**self.image_processor_dict							)
   # create random PIL images
   _a						: Optional[int]    =			self.image_processor_tester.prepare_inputs(equal_resolution=UpperCAmelCase__							)
   for image in image_inputs:
     self.assertIsInstance(UpperCAmelCase__							,		Image.Image							)

   # Test not batched input
   _a						: str    =			image_processor(image_inputs[0]							,		return_tensors="""pt"""							).pixel_values
   _a   ,						_a						: Optional[Any]    =			self.calculate_expected_size(np.array(image_inputs[0]							)							)
   self.assertEqual(
       encoded_images.shape							,		(
           1,
           self.image_processor_tester.num_channels,
           expected_height,
           expected_width,
       )							,		)


 def _lowercase			(  self	:		Optional[Any]							)      -> Union[str, Any]:
   # Initialize image_processor
   _a						: int    =			self.image_processing_class(**self.image_processor_dict							)
   # create random numpy tensors
   _a						: str    =			self.image_processor_tester.prepare_inputs(equal_resolution=UpperCAmelCase__							,		numpify=UpperCAmelCase__							)
   for image in image_inputs:
     self.assertIsInstance(UpperCAmelCase__							,		np.ndarray							)

   # Test not batched input
   _a						: Any    =			image_processor(image_inputs[0]							,		return_tensors="""pt"""							).pixel_values
   _a   ,						_a						: Dict    =			self.calculate_expected_size(image_inputs[0]							)
   self.assertEqual(
       encoded_images.shape							,		(
           1,
           self.image_processor_tester.num_channels,
           expected_height,
           expected_width,
       )							,		)







 def _lowercase			(  self	:		Any							)      -> List[str]:
   # Initialize image_processor
   _a						: Optional[int]    =			self.image_processing_class(**self.image_processor_dict							)
   # create random PyTorch tensors
   _a						: List[Any]    =			self.image_processor_tester.prepare_inputs(equal_resolution=UpperCAmelCase__							,		torchify=UpperCAmelCase__							)
   for image in image_inputs:
     self.assertIsInstance(UpperCAmelCase__							,		torch.Tensor							)

   # Test not batched input
   _a						: Optional[int]    =			image_processor(image_inputs[0]							,		return_tensors="""pt"""							).pixel_values
   _a   ,						_a						: Any    =			self.calculate_expected_size(image_inputs[0]							)
   self.assertEqual(
       encoded_images.shape							,		(
           1,
           self.image_processor_tester.num_channels,
           expected_height,
           expected_width,
       )							,		)









"""simple docstring"""




from __future__ import annotations

import sys

def     lowerCAmelCase__  (  UpperCamelCase__       ):



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

def     lowerCAmelCase__  (  UpperCamelCase__       ):



  '''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
  _a   ,						_a						: Dict    =			_fib(n // 2       )
  _a						: Dict    =			a * (b * 2 - a)
  _a						: Optional[Any]    =			a * a + b * b
  return (d, c + d) if n % 2 else (c, d)


if __name__ == "__main__":
 _snake_case					   =     int(sys.argv[1])
 print(F'''fibonacci({n}) is {fibonacci(n)}''')

