





import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import is_torch_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask


if is_torch_available():
       import torch

       from transformers import BlipTextModel
       from transformers.models.blip.modeling_blip import BLIP_PRETRAINED_MODEL_ARCHIVE_LIST





class 	lowerCAmelCase__:






       '''simple docstring'''


       def __init__(					self			,  __lowerCamelCase			,  __lowerCamelCase=1_2			,  __lowerCamelCase=7			,  __lowerCamelCase=True			,  __lowerCamelCase=True			,  __lowerCamelCase=True			,  __lowerCamelCase=9_9			,  __lowerCamelCase=3_2			,  __lowerCamelCase=3_2			,  __lowerCamelCase=5			,  __lowerCamelCase=4			,  __lowerCamelCase=3_7			,  __lowerCamelCase=0.1			,  __lowerCamelCase=0.1			,  __lowerCamelCase=5_1_2			,  __lowerCamelCase=0.02			,  __lowerCamelCase=0			,  __lowerCamelCase=None			,  )	->   Union[str, Any]:
            _SCREAMING_SNAKE_CASE				:		Any  			=							parent
            _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							batch_size
            _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							seq_length
            _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							is_training
            _SCREAMING_SNAKE_CASE				:		str  			=							use_input_mask
            _SCREAMING_SNAKE_CASE				:		List[str]  			=							use_labels
            _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							vocab_size
            _SCREAMING_SNAKE_CASE				:		Optional[Any]  			=							hidden_size
            _SCREAMING_SNAKE_CASE				:		Tuple  			=							projection_dim
            _SCREAMING_SNAKE_CASE				:		List[str]  			=							num_hidden_layers
            _SCREAMING_SNAKE_CASE				:		str  			=							num_attention_heads
            _SCREAMING_SNAKE_CASE				:		Tuple  			=							intermediate_size
            _SCREAMING_SNAKE_CASE				:		Tuple  			=							dropout
            _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							attention_dropout
            _SCREAMING_SNAKE_CASE				:		List[str]  			=							max_position_embeddings
            _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							initializer_range
            _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							scope
            _SCREAMING_SNAKE_CASE				:		List[str]  			=							bos_token_id




       def 			UpperCamelCase_	(					self							)	->   Optional[Any]:
            _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							ids_tensor([self.batch_size, self.seq_length]			,  self.vocab_size							)

            _SCREAMING_SNAKE_CASE				:		List[str]  			=							None
            if self.use_input_mask:
                 _SCREAMING_SNAKE_CASE				:		List[Any]  			=							random_attention_mask([self.batch_size, self.seq_length]							)

            if input_mask is not None:
                 _SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE				:		Optional[int]  			=							input_mask.shape
                 _SCREAMING_SNAKE_CASE				:		List[str]  			=							np.random.randint(1			,  seq_length - 1			,  size=(batch_size,)							)
                 for batch_idx, start_index in enumerate(__lowerCamelCase							):
                      _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							1
                      _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							0

            _SCREAMING_SNAKE_CASE				:		str  			=							self.get_config()

            return config, input_ids, input_mask




       def 			UpperCamelCase_	(					self							)	->   Union[str, Any]:
            return BlipTextConfig(
                vocab_size=self.vocab_size			,  hidden_size=self.hidden_size			,  projection_dim=self.projection_dim			,  num_hidden_layers=self.num_hidden_layers			,  num_attention_heads=self.num_attention_heads			,  intermediate_size=self.intermediate_size			,  dropout=self.dropout			,  attention_dropout=self.attention_dropout			,  max_position_embeddings=self.max_position_embeddings			,  initializer_range=self.initializer_range			,  bos_token_id=self.bos_token_id			,  )




       def 			UpperCamelCase_	(					self			,  __lowerCamelCase			,  __lowerCamelCase			,  __lowerCamelCase							)	->   Tuple:
            _SCREAMING_SNAKE_CASE				:		str  			=							BlipTextModel(config=__lowerCamelCase							)
            model.to(__lowerCamelCase							)
            model.eval()
            with torch.no_grad():
                 _SCREAMING_SNAKE_CASE				:		str  			=							model(__lowerCamelCase			,  attention_mask=__lowerCamelCase							)
                 _SCREAMING_SNAKE_CASE				:		Any  			=							model(__lowerCamelCase							)
            self.parent.assertEqual(result.last_hidden_state.shape			,  (self.batch_size, self.seq_length, self.hidden_size)							)
            self.parent.assertEqual(result.pooler_output.shape			,  (self.batch_size, self.hidden_size)							)







       def 			UpperCamelCase_	(					self							)	->   Optional[int]:
            _SCREAMING_SNAKE_CASE				:		int  			=							self.prepare_config_and_inputs()
            _SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE				:		Dict  			=							config_and_inputs
            _SCREAMING_SNAKE_CASE				:		Tuple  			=							{"input_ids": input_ids, "attention_mask": input_mask}
            return config, inputs_dict





@require_torch
class 	lowerCAmelCase__(       __lowercase     ,   unittest.TestCase			):






       '''simple docstring'''


       __snake_case       	=			(BlipTextModel,) if is_torch_available() else ()
       __snake_case       	=			False
       __snake_case       	=			False
       __snake_case       	=			False




       def 			UpperCamelCase_	(					self							)	->   List[Any]:
            _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							BlipTextModelTester(self							)
            _SCREAMING_SNAKE_CASE				:		int  			=							ConfigTester(self			,  config_class=__lowerCamelCase			,  hidden_size=3_7							)




       def 			UpperCamelCase_	(					self							)	->   int:
            self.config_tester.run_common_tests()




       def 			UpperCamelCase_	(					self							)	->   Union[str, Any]:
            _SCREAMING_SNAKE_CASE				:		Tuple  			=							self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_model(*__lowerCamelCase							)




       def 			UpperCamelCase_	(					self							)	->   str:
            pass




       def 			UpperCamelCase_	(					self							)	->   List[str]:
            pass




       @unittest.skip(reason="Blip does not use inputs_embeds"							)
       def 			UpperCamelCase_	(					self							)	->   Dict:
            pass




       @unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"							)
       def 			UpperCamelCase_	(					self							)	->   int:
            pass




       @unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"							)
       def 			UpperCamelCase_	(					self							)	->   Union[str, Any]:
            pass




       @slow
       def 			UpperCamelCase_	(					self							)	->   int:
            for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                 _SCREAMING_SNAKE_CASE				:		int  			=							BlipTextModel.from_pretrained(__lowerCamelCase							)
                 self.assertIsNotNone(__lowerCamelCase							)







       def 			UpperCamelCase_	(					self							)	->   List[str]:
            super().test_pt_tf_model_equivalence(allow_missing_keys=__lowerCamelCase							)






import sys

sys.set_int_max_str_digits(0)  # type: ignore






def 			lowerCamelCase__	(__lowerCamelCase		):
     _SCREAMING_SNAKE_CASE				:		int  			=							[0] * 11
     _SCREAMING_SNAKE_CASE				:		Optional[Any]  			=							[0] * 11

     # mark last 9 numbers
     for _ in range(9		):
          _SCREAMING_SNAKE_CASE				:		Optional[Any]  			=							1
          _SCREAMING_SNAKE_CASE				:		str  			=							number // 10
     # flag
     _SCREAMING_SNAKE_CASE				:		int  			=							True

     # check last 9 numbers for pandigitality

     for x in range(9		):
          if not check_last[x + 1]:
               _SCREAMING_SNAKE_CASE				:		Any  			=							False
     if not f:
          return f

     # mark first 9 numbers
     _SCREAMING_SNAKE_CASE				:		str  			=							int(str(__lowerCamelCase		)[:9]		)

     for _ in range(9		):
          _SCREAMING_SNAKE_CASE				:		str  			=							1
          _SCREAMING_SNAKE_CASE				:		List[Any]  			=							number // 10

     # check first 9 numbers for pandigitality

     for x in range(9		):
          if not check_front[x + 1]:
               _SCREAMING_SNAKE_CASE				:		Any  			=							False
     return f






def 			lowerCamelCase__	(__lowerCamelCase		):
     _SCREAMING_SNAKE_CASE				:		List[str]  			=							[0] * 11

     # mark last 9 numbers
     for _ in range(9		):
          _SCREAMING_SNAKE_CASE				:		Dict  			=							1
          _SCREAMING_SNAKE_CASE				:		List[str]  			=							number // 10
     # flag
     _SCREAMING_SNAKE_CASE				:		List[Any]  			=							True

     # check last 9 numbers for pandigitality

     for x in range(9		):
          if not check_last[x + 1]:
               _SCREAMING_SNAKE_CASE				:		str  			=							False
     return f






def 			lowerCamelCase__	():
     _SCREAMING_SNAKE_CASE				:		Dict  			=							1
     _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							1
     _SCREAMING_SNAKE_CASE				:		List[str]  			=							2
     # temporary Fibonacci numbers

     _SCREAMING_SNAKE_CASE				:		Any  			=							1
     _SCREAMING_SNAKE_CASE				:		List[str]  			=							1
     _SCREAMING_SNAKE_CASE				:		str  			=							2
     # temporary Fibonacci numbers mod 1e9

     # mod m=1e9, done for fast optimisation
     _SCREAMING_SNAKE_CASE				:		Optional[Any]  			=							[0] * 1000000
     _SCREAMING_SNAKE_CASE				:		Optional[int]  			=							1000000000

     for x in range(1000000		):
          _SCREAMING_SNAKE_CASE				:		Union[str, Any]  			=							(aa + ba) % m
          _SCREAMING_SNAKE_CASE				:		int  			=							ba % m
          _SCREAMING_SNAKE_CASE				:		List[str]  			=							ca % m
          if checka(__lowerCamelCase		):
               _SCREAMING_SNAKE_CASE				:		List[Any]  			=							1

     for x in range(1000000		):
          _SCREAMING_SNAKE_CASE				:		Any  			=							a + b
          _SCREAMING_SNAKE_CASE				:		Dict  			=							b
          _SCREAMING_SNAKE_CASE				:		int  			=							c
          # perform check only if in tocheck
          if tocheck[x + 3] and check(__lowerCamelCase		):
               return x + 3  # first 2 already done
     return -1


if __name__ == "__main__":
       print(f"{solution() = }")