




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        __lowerCAmelCase					:

			"""simple docstring"""







			def __init__( self     ,		lowerCamelCase__     ,		lowerCamelCase__=12     ,		lowerCamelCase__=7     ,		lowerCamelCase__=True     ,		lowerCamelCase__=True     ,		lowerCamelCase__=True     ,		lowerCamelCase__=99     ,		lowerCamelCase__=32     ,		lowerCamelCase__=32     ,		lowerCamelCase__=2     ,		lowerCamelCase__=4     ,		lowerCamelCase__=37     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=512     ,		lowerCamelCase__=0.02     ,		lowerCamelCase__=0     ,		lowerCamelCase__=None     ,		)       -> List[Any]:



							'''simple docstring'''
							__lowerCamelCase									=       parent
							__lowerCamelCase									=       batch_size
							__lowerCamelCase									=       seq_length
							__lowerCamelCase									=       is_training
							__lowerCamelCase									=       use_input_mask
							__lowerCamelCase									=       use_labels
							__lowerCamelCase									=       vocab_size
							__lowerCamelCase									=       hidden_size
							__lowerCamelCase									=       projection_dim
							__lowerCamelCase									=       num_hidden_layers
							__lowerCamelCase									=       num_attention_heads
							__lowerCamelCase									=       intermediate_size
							__lowerCamelCase									=       dropout
							__lowerCamelCase									=       attention_dropout
							__lowerCamelCase									=       max_position_embeddings
							__lowerCamelCase									=       initializer_range
							__lowerCamelCase									=       scope
							__lowerCamelCase									=       bos_token_id


			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							__lowerCamelCase									=       ids_tensor([self.batch_size, self.seq_length]     ,		self.vocab_size				)

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

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

							__lowerCamelCase									=       self.get_config()

							return config, input_ids, tf.convert_to_tensor(lowerCamelCase__				)


			def  lowercase_       ( self				)       -> Any:



							'''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  lowercase_       ( self     ,		lowerCamelCase__     ,		lowerCamelCase__     ,		lowerCamelCase__				)       -> Optional[Any]:



							'''simple docstring'''
							__lowerCamelCase									=       TFBlipTextModel(config=lowerCamelCase__				)
							__lowerCamelCase									=       model(lowerCamelCase__     ,		attention_mask=lowerCamelCase__     ,		training=lowerCamelCase__				)
							__lowerCamelCase									=       model(lowerCamelCase__     ,		training=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  lowercase_       ( self				)       -> Any:



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







@require_tf
class        __lowerCAmelCase					(			__magic_name__     ,							unittest.TestCase					):

			"""simple docstring"""







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


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



							'''simple docstring'''
							__lowerCamelCase									=       BlipTextModelTester(self				)
							__lowerCamelCase									=       ConfigTester(self     ,		config_class=lowerCamelCase__     ,		hidden_size=37				)


			def  lowercase_       ( self				)       -> List[str]:



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


			def  lowercase_       ( self				)       -> Union[str, Any]:



							'''simple docstring'''
							__lowerCamelCase									=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*lowerCamelCase__				)


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



							'''simple docstring'''
							pass


			def  lowercase_       ( self				)       -> List[str]:



							'''simple docstring'''
							pass


			@unittest.skip(reason='Blip does not use inputs_embeds'				)
			def  lowercase_       ( self				)       -> Optional[Any]:



							'''simple docstring'''
							pass


			@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'				)
			def  lowercase_       ( self				)       -> List[Any]:



							'''simple docstring'''
							pass


			@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'				)
			def  lowercase_       ( self				)       -> Tuple:



							'''simple docstring'''
							pass


			@slow
			def  lowercase_       ( self				)       -> Tuple:



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






			def  lowercase_       ( self     ,		lowerCamelCase__=True				)       -> Dict:



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








def      lowerCamelCase_						(			)	->			List[str]:





				"""simple docstring"""


				__lowerCamelCase									=       0
				for i in range(1					,	1001 ):
								total += i**i
				return str(UpperCamelCase__ )[-10:]


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


