'''simple docstring'''

import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers.testing_utils import require_vision
from transformers.utils import is_vision_available


if is_vision_available():
  from PIL import Image

  from transformers import AutoProcessor, BertTokenizer, BlipImageProcessor, BlipProcessor, PreTrainedTokenizerFast



@require_vision
class       UpperCAmelCase  (						unittest.TestCase ):





       '''simple docstring'''



       def _lowerCAmelCase(						self			)  ->  Union[str, Any]:
        lowercase__    :   Dict						= tempfile.mkdtemp()

        lowercase__    :   List[Any]						= BlipImageProcessor()
        lowercase__    :   int						= BertTokenizer.from_pretrained('''hf-internal-testing/tiny-random-BertModel'''			)

        lowercase__    :   int						= BlipProcessor(__lowerCAmelCase     ,       __lowerCAmelCase			)

        processor.save_pretrained(self.tmpdirname			)

       def _lowerCAmelCase(						self     ,       **__lowerCAmelCase			)  ->  List[Any]:
        return AutoProcessor.from_pretrained(self.tmpdirname     ,       **__lowerCAmelCase			).tokenizer

       def _lowerCAmelCase(						self     ,       **__lowerCAmelCase			)  ->  Dict:
        return AutoProcessor.from_pretrained(self.tmpdirname     ,       **__lowerCAmelCase			).image_processor

       def _lowerCAmelCase(						self			)  ->  int:
        shutil.rmtree(self.tmpdirname			)

       def _lowerCAmelCase(						self			)  ->  int:
        lowercase__    :   Dict						= [np.random.randint(255     ,       size=(3, 30, 400)     ,       dtype=np.uinta			)]

        lowercase__    :   Tuple						= [Image.fromarray(np.moveaxis(__lowerCAmelCase     ,       0     ,       -1			)			) for x in image_inputs]

        return image_inputs

       def _lowerCAmelCase(						self			)  ->  Optional[int]:
        lowercase__    :   Any						= BlipProcessor(tokenizer=self.get_tokenizer()     ,       image_processor=self.get_image_processor()			)
        processor.save_pretrained(self.tmpdirname			)

        lowercase__    :   List[Any]						= self.get_tokenizer(bos_token='''(BOS)'''     ,       eos_token='''(EOS)'''			)
        lowercase__    :   str						= self.get_image_processor(do_normalize=__lowerCAmelCase     ,       padding_value=1.0			)

        lowercase__    :   Dict						= BlipProcessor.from_pretrained(
            self.tmpdirname     ,       bos_token='''(BOS)'''     ,       eos_token='''(EOS)'''     ,       do_normalize=__lowerCAmelCase     ,       padding_value=1.0			)

        self.assertEqual(processor.tokenizer.get_vocab()     ,       tokenizer_add_kwargs.get_vocab()			)
        self.assertIsInstance(processor.tokenizer     ,       __lowerCAmelCase			)

        self.assertEqual(processor.image_processor.to_json_string()     ,       image_processor_add_kwargs.to_json_string()			)
        self.assertIsInstance(processor.image_processor     ,       __lowerCAmelCase			)

       def _lowerCAmelCase(						self			)  ->  Union[str, Any]:
        lowercase__    :   Optional[Any]						= self.get_image_processor()
        lowercase__    :   Optional[int]						= self.get_tokenizer()

        lowercase__    :   List[str]						= BlipProcessor(tokenizer=__lowerCAmelCase     ,       image_processor=__lowerCAmelCase			)

        lowercase__    :   Any						= self.prepare_image_inputs()

        lowercase__    :   Tuple						= image_processor(__lowerCAmelCase     ,       return_tensors='''np'''			)
        lowercase__    :   str						= processor(images=__lowerCAmelCase     ,       return_tensors='''np'''			)

        for key in input_feat_extract.keys():
         self.assertAlmostEqual(input_feat_extract[key].sum()     ,       input_processor[key].sum()     ,       delta=1E-2			)

       def _lowerCAmelCase(						self			)  ->  Any:
        lowercase__    :   int						= self.get_image_processor()
        lowercase__    :   Any						= self.get_tokenizer()

        lowercase__    :   Optional[Any]						= BlipProcessor(tokenizer=__lowerCAmelCase     ,       image_processor=__lowerCAmelCase			)

        lowercase__    :   Union[str, Any]						= '''lower newer'''

        lowercase__    :   Optional[Any]						= processor(text=__lowerCAmelCase			)

        lowercase__    :   Dict						= tokenizer(__lowerCAmelCase     ,       return_token_type_ids=__lowerCAmelCase			)

        for key in encoded_tok.keys():
         self.assertListEqual(encoded_tok[key]     ,       encoded_processor[key]			)

       def _lowerCAmelCase(						self			)  ->  Tuple:
        lowercase__    :   Tuple						= self.get_image_processor()
        lowercase__    :   Tuple						= self.get_tokenizer()

        lowercase__    :   List[Any]						= BlipProcessor(tokenizer=__lowerCAmelCase     ,       image_processor=__lowerCAmelCase			)

        lowercase__    :   Tuple						= '''lower newer'''
        lowercase__    :   Union[str, Any]						= self.prepare_image_inputs()

        lowercase__    :   Optional[int]						= processor(text=__lowerCAmelCase     ,       images=__lowerCAmelCase			)

        self.assertListEqual(list(inputs.keys()			)     ,       ['''pixel_values''', '''input_ids''', '''attention_mask''']			)

        # test if it raises when no input is passed
        with pytest.raises(__lowerCAmelCase			):
         processor()

       def _lowerCAmelCase(						self			)  ->  Tuple:
        lowercase__    :   Optional[int]						= self.get_image_processor()
        lowercase__    :   Optional[int]						= self.get_tokenizer()

        lowercase__    :   Tuple						= BlipProcessor(tokenizer=__lowerCAmelCase     ,       image_processor=__lowerCAmelCase			)

        lowercase__    :   int						= [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

        lowercase__    :   Tuple						= processor.batch_decode(__lowerCAmelCase			)
        lowercase__    :   str						= tokenizer.batch_decode(__lowerCAmelCase			)

        self.assertListEqual(__lowerCAmelCase     ,       __lowerCAmelCase			)


       def _lowerCAmelCase(						self			)  ->  str:
        lowercase__    :   str						= self.get_image_processor()
        lowercase__    :   str						= self.get_tokenizer()

        lowercase__    :   List[str]						= BlipProcessor(tokenizer=__lowerCAmelCase     ,       image_processor=__lowerCAmelCase			)

        lowercase__    :   Union[str, Any]						= '''lower newer'''
        lowercase__    :   Any						= self.prepare_image_inputs()

        lowercase__    :   str						= processor(text=__lowerCAmelCase     ,       images=__lowerCAmelCase			)

        # For now the processor supports only ['pixel_values', 'input_ids', 'attention_mask']
        self.assertListEqual(list(inputs.keys()			)     ,       ['''pixel_values''', '''input_ids''', '''attention_mask''']			)


'''simple docstring'''

def       __UpperCamelCase	(       ):
 lowercase__    :   Any						= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

 lowercase__    :   Any						= 6
 lowercase__    :   Optional[Any]						= 1
 lowercase__    :   int						= 1901

 lowercase__    :   List[str]						= 0

 while year < 2001:
  day += 7

  if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
   if day > days_per_month[month - 1] and month != 2:
    month += 1
    lowercase__    :   List[Any]						= day - days_per_month[month - 2]
   elif day > 29 and month == 2:
    month += 1
    lowercase__    :   Any						= day - 29
  else:
   if day > days_per_month[month - 1]:
    month += 1
    lowercase__    :   List[Any]						= day - days_per_month[month - 2]

  if month > 12:
   year += 1
   lowercase__    :   Dict						= 1

  if year < 2001 and day == 1:
   sundays += 1
 return sundays


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

