





'''simple docstring'''







from __future__ import annotations

import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_tf, slow
from transformers.utils import is_tf_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask


if is_tf_available():
					import tensorflow as tf

					from transformers import TFBlipTextModel
					from transformers.models.blip.modeling_tf_blip import TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST
class 				__SCREAMING_SNAKE_CASE  :






				"""simple docstring"""







				def __init__(  self     :					List[str]					,				__a     :					str					,				__a     :					Any=12					,				__a     :					Union[str, Any]=7					,				__a     :					str=True					,				__a     :					Dict=True					,				__a     :					List[str]=True					,				__a     :					Union[str, Any]=99					,				__a     :					List[str]=32					,				__a     :					Optional[int]=32					,				__a     :					Any=2					,				__a     :					Any=4					,				__a     :					List[str]=37					,				__a     :					Dict=0.1					,				__a     :					Any=0.1					,				__a     :					Union[str, Any]=5_12					,				__a     :					List[str]=0.02					,				__a     :					int=0					,				__a     :					str=None					,				):
								_a								= parent
								_a								= batch_size
								_a								= seq_length
								_a								= is_training
								_a								= use_input_mask
								_a								= use_labels
								_a								= vocab_size
								_a								= hidden_size
								_a								= projection_dim
								_a								= num_hidden_layers
								_a								= num_attention_heads
								_a								= intermediate_size
								_a								= dropout
								_a								= attention_dropout
								_a								= max_position_embeddings
								_a								= initializer_range
								_a								= scope
								_a								= bos_token_id




				def   UpperCamelCase__   (  self     :					Optional[int]					):
								_a								= ids_tensor([self.batch_size, self.seq_length]					,				self.vocab_size					)

								_a								= None
								if self.use_input_mask:
												_a								= random_attention_mask([self.batch_size, self.seq_length]					)

								if input_mask is not None:
												_a								= input_mask.numpy()
												_a								= input_mask.shape
												_a								= np.random.randint(1					,				seq_length - 1					,				size=(batch_size,)					)
												for batch_idx, start_index in enumerate(UpperCamelCase__					):
																_a								= 1
																_a								= 0

								_a								= self.get_config()

								return config, input_ids, tf.convert_to_tensor(UpperCamelCase__					)




				def   UpperCamelCase__   (  self     :					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     :					Tuple					,				__a     :					Optional[int]					,				__a     :					str					,				__a     :					Optional[int]					):
								_a								= TFBlipTextModel(config=UpperCamelCase__					)
								_a								= model(UpperCamelCase__					,				attention_mask=UpperCamelCase__					,				training=UpperCamelCase__					)
								_a								= model(UpperCamelCase__					,				training=UpperCamelCase__					)
								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]					):
								_a								= self.prepare_config_and_inputs()
								_a								= config_and_inputs
								_a								= {"input_ids": input_ids, "attention_mask": input_mask}
								return config, inputs_dict


@require_tf
class 				__SCREAMING_SNAKE_CASE  (snake_case_       ,							unittest.TestCase      ):






				"""simple docstring"""







				__a            =(TFBlipTextModel,) if is_tf_available() else ()
				__a            =False
				__a            =False
				__a            =False




				def   UpperCamelCase__   (  self     :					List[str]					):
								_a								= BlipTextModelTester(self					)
								_a								= ConfigTester(self					,				config_class=UpperCamelCase__					,				hidden_size=37					)




				def   UpperCamelCase__   (  self     :					str					):
								self.config_tester.run_common_tests()




				def   UpperCamelCase__   (  self     :					Dict					):
								_a								= self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*UpperCamelCase__					)




				def   UpperCamelCase__   (  self     :					Union[str, Any]					):
								pass




				def   UpperCamelCase__   (  self     :					Tuple					):
								pass




				@unittest.skip(reason="Blip does not use inputs_embeds"					)
				def   UpperCamelCase__   (  self     :					List[str]					):
								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     :					Tuple					):
								pass




				@slow
				def   UpperCamelCase__   (  self     :					Optional[Any]					):




								for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												_a								= TFBlipTextModel.from_pretrained(UpperCamelCase__					)
												self.assertIsNotNone(UpperCamelCase__					)




				def   UpperCamelCase__   (  self     :					int					,				__a     :					Union[str, Any]=True					):
								super().test_pt_tf_model_equivalence(allow_missing_keys=UpperCamelCase__					)




"""simple docstring"""



def   __lowerCAmelCase						(						lowercase  :  int )	->						bool:


    """simple docstring"""





    if p < 2:
        raise ValueError("p should not be less than 2!" )
    elif p == 2:
        return True

    snake_case    :      Dict      					=    4
    snake_case    :      str      					=    (1 << p) - 1
    for _ in range(p - 2 ):
        snake_case    :      Any      					=    ((s * s) - 2) % m
    return s == 0


if __name__ == "__main__":
  print(lucas_lehmer_test(7))
  print(lucas_lehmer_test(11))





