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 LevitImageProcessor

class 						A__							(		unittest.TestCase  ):




						def __init__(       self					:      str				,    _a					:      List[Any]				,    _a					:      Any=7				,    _a					:      Tuple=3				,    _a					:      Optional[int]=18				,    _a					:      str=30				,    _a					:      Any=400				,    _a					:      str=True				,    _a					:      int=None				,    _a					:      int=True				,    _a					:      int=None				,    _a					:      Tuple=True				,    _a					:      Any=[0.5, 0.5, 0.5]				,    _a					:      str=[0.5, 0.5, 0.5]				,    )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =size if size is not None else {'''shortest_edge''': 18}
										_SCREAMING_SNAKE_CASE			  =crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
										_SCREAMING_SNAKE_CASE			  =parent
										_SCREAMING_SNAKE_CASE			  =batch_size
										_SCREAMING_SNAKE_CASE			  =num_channels
										_SCREAMING_SNAKE_CASE			  =image_size
										_SCREAMING_SNAKE_CASE			  =min_resolution
										_SCREAMING_SNAKE_CASE			  =max_resolution
										_SCREAMING_SNAKE_CASE			  =do_resize
										_SCREAMING_SNAKE_CASE			  =size
										_SCREAMING_SNAKE_CASE			  =do_center_crop
										_SCREAMING_SNAKE_CASE			  =crop_size
										_SCREAMING_SNAKE_CASE			  =do_normalize
										_SCREAMING_SNAKE_CASE			  =image_mean
										_SCREAMING_SNAKE_CASE			  =image_std




						def 							__UpperCamelCase				(       self					:      Tuple  )							->     Dict:


										"""simple docstring"""





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

@require_torch
@require_vision
class 						A__							(		__lowercase   ,     unittest.TestCase  ):
						UpperCAmelCase             =						LevitImageProcessor if is_vision_available() else None




						def 							__UpperCamelCase				(       self					:      Optional[int]  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =LevitImageProcessingTester(self  )




						@property
						def 							__UpperCamelCase				(       self					:      Optional[int]  )							->     int:


										"""simple docstring"""





										return self.image_processor_tester.prepare_image_processor_dict()




						def 							__UpperCamelCase				(       self					:      int  )							->     List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.image_processing_class(**self.image_processor_dict  )
										self.assertTrue(hasattr(__A				,    '''image_mean'''  )  )
										self.assertTrue(hasattr(__A				,    '''image_std'''  )  )
										self.assertTrue(hasattr(__A				,    '''do_normalize'''  )  )
										self.assertTrue(hasattr(__A				,    '''do_resize'''  )  )
										self.assertTrue(hasattr(__A				,    '''do_center_crop'''  )  )
										self.assertTrue(hasattr(__A				,    '''size'''  )  )




						def 							__UpperCamelCase				(       self					:      Dict  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.image_processing_class.from_dict(self.image_processor_dict  )
										self.assertEqual(image_processor.size				,    {'''shortest_edge''': 18}  )
										self.assertEqual(image_processor.crop_size				,    {'''height''': 18, '''width''': 18}  )

										_SCREAMING_SNAKE_CASE			  =self.image_processing_class.from_dict(self.image_processor_dict				,    size=42				,    crop_size=84  )
										self.assertEqual(image_processor.size				,    {'''shortest_edge''': 42}  )
										self.assertEqual(image_processor.crop_size				,    {'''height''': 84, '''width''': 84}  )




						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     List[str]:


										"""simple docstring"""





										pass




						def 							__UpperCamelCase				(       self					:      Any  )							->     Optional[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.image_processing_class(**self.image_processor_dict  )
										# create random PIL images
										_SCREAMING_SNAKE_CASE			  =prepare_image_inputs(self.image_processor_tester				,    equal_resolution=__A  )
										for image in image_inputs:
														self.assertIsInstance(__A				,    Image.Image  )

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

										# Test batched
										_SCREAMING_SNAKE_CASE			  =image_processing(__A				,    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.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    )				,    )




						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.image_processing_class(**self.image_processor_dict  )
										# create random numpy tensors
										_SCREAMING_SNAKE_CASE			  =prepare_image_inputs(self.image_processor_tester				,    equal_resolution=__A				,    numpify=__A  )
										for image in image_inputs:
														self.assertIsInstance(__A				,    np.ndarray  )

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

										# Test batched
										_SCREAMING_SNAKE_CASE			  =image_processing(__A				,    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.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    )				,    )




						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     int:


										"""simple docstring"""





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

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

										# Test batched
										_SCREAMING_SNAKE_CASE			  =image_processing(__A				,    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.crop_size['''height'''],
										        self.image_processor_tester.crop_size['''width'''],
										    )				,    )



snake_case_						:			dict[tuple[int, int, int], int]													=							{}







def 						lowerCamelCase(   a__	,a__	,a__):

				# if we are absent twice, or late 3 consecutive days,
				# no further prize strings are possible
				if late == 3 or absent == 2:
								return 0

				# if we have no days left, and have not failed any other rules,
				# we have a prize string
				if days == 0:
								return 1

				# No easy solution, so now we need to do the recursive calculation

				# First, check if the combination is already in the cache, and
				# if yes, return the stored value from there since we already
				# know the number of possible prize strings from this point on
				_SCREAMING_SNAKE_CASE			  =(days, absent, late)
				if key in cache:
								return cache[key]

				# now we calculate the three possible ways that can unfold from
				# this point on, depending on our attendance today

				# 1) if we are late (but not absent), the "absent" counter stays as
				# it is, but the "late" counter increases by one
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,a__	,late + 1)

				# 2) if we are absent, the "absent" counter increases by 1, and the
				# "late" counter resets to 0
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,absent + 1	,0)

				# 3) if we are on time, this resets the "late" counter and keeps the
				# absent counter
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,a__	,0)

				_SCREAMING_SNAKE_CASE			  =state_late + state_absent + state_ontime

				_SCREAMING_SNAKE_CASE			  =prizestrings
				return prizestrings







def 						lowerCamelCase(   a__ = 30):
				return _calculate(a__	,absent=0	,late=0)


if __name__ == "__main__":
							print(solution())