





'''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       UpperCamelCase__  :







	def __init__(				self			:   Dict , lowerCamelCase			:   int , lowerCamelCase			:   int=1_2 , lowerCamelCase			:   Union[str, Any]=7 , lowerCamelCase			:   List[Any]=True , lowerCamelCase			:   str=True , lowerCamelCase			:   Optional[Any]=True , lowerCamelCase			:   str=9_9 , lowerCamelCase			:   Any=3_2 , lowerCamelCase			:   Tuple=3_2 , lowerCamelCase			:   List[str]=2 , lowerCamelCase			:   Dict=4 , lowerCamelCase			:   int=3_7 , lowerCamelCase			:   Optional[int]=0.1 , lowerCamelCase			:   Any=0.1 , lowerCamelCase			:   int=5_1_2 , lowerCamelCase			:   str=0.02 , lowerCamelCase			:   int=0 , lowerCamelCase			:   str=None , ):




				'''simple docstring'''
				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 						__a   (				self			:   Any		):




				'''simple docstring'''
				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__   ,				a__     = input_mask.shape
							a__     = np.random.randint(1 , seq_length - 1 , size=(batch_size,)		)
							for batch_idx, start_index in enumerate(A_		):
										a__     = 1
										a__     = 0

				a__     = self.get_config()

				return config, input_ids, tf.convert_to_tensor(A_		)







	def 						__a   (				self			:   List[str]		):




				'''simple docstring'''
				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 						__a   (				self			:   Union[str, Any] , lowerCamelCase			:   int , lowerCamelCase			:   Optional[int] , lowerCamelCase			:   Optional[int]		):




				'''simple docstring'''
				a__     = TFBlipTextModel(config=A_		)
				a__     = model(A_ , attention_mask=A_ , training=A_		)
				a__     = model(A_ , training=A_		)
				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 						__a   (				self			:   Optional[Any]		):




				'''simple docstring'''
				a__     = self.prepare_config_and_inputs()
				a__   ,				a__   ,				a__     = config_and_inputs
				a__     = {"input_ids": input_ids, "attention_mask": input_mask}
				return config, inputs_dict






@require_tf
class       UpperCamelCase__  (		_lowercase	,unittest.TestCase     ):
	lowerCAmelCase__					:			Tuple								=						(TFBlipTextModel,) if is_tf_available() else ()
	lowerCAmelCase__					:			Any								=						False
	lowerCAmelCase__					:			Any								=						False
	lowerCAmelCase__					:			List[str]								=						False







	def 						__a   (				self			:   List[str]		):




				'''simple docstring'''
				a__     = BlipTextModelTester(self		)
				a__     = ConfigTester(self , config_class=A_ , hidden_size=3_7		)







	def 						__a   (				self			:   Optional[int]		):




				'''simple docstring'''
				self.config_tester.run_common_tests()







	def 						__a   (				self			:   Dict		):




				'''simple docstring'''
				a__     = self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_model(*A_		)







	def 						__a   (				self			:   List[str]		):




				'''simple docstring'''
				pass







	def 						__a   (				self			:   List[Any]		):




				'''simple docstring'''
				pass







	@unittest.skip(reason="Blip does not use inputs_embeds"		)
	def 						__a   (				self			:   str		):




				'''simple docstring'''
				pass







	@unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"		)
	def 						__a   (				self			:   Dict		):




				'''simple docstring'''
				pass







	@unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"		)
	def 						__a   (				self			:   Optional[Any]		):




				'''simple docstring'''
				pass







	@slow
	def 						__a   (				self			:   str		):




				'''simple docstring'''
				for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							a__     = TFBlipTextModel.from_pretrained(A_		)
							self.assertIsNotNone(A_		)







	def 						__a   (				self			:   List[str] , lowerCamelCase			:   Optional[Any]=True		):




				'''simple docstring'''
				super().test_pt_tf_model_equivalence(allow_missing_keys=A_		)












'''simple docstring'''


import re







def    _lowerCamelCase  (__lowerCamelCase  :     str     )   ->    bool:
			a__     = re.compile(
			    r"^(?:0|94|\+94|0{2}94)" r"7(0|1|2|4|5|6|7|8)" r"(-| |)" r"\d{7}$"     )

			return bool(re.search(__lowerCamelCase					,  __lowerCamelCase     )     )


if __name__ == "__main__":
		lowerCAmelCase_   :   Any       =					"0094702343221"

		print(is_sri_lankan_phone_number(phone))



