



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 :




				def __init__(							self						,				_snake_case						,				_snake_case=12						,				_snake_case=7						,				_snake_case=True						,				_snake_case=True						,				_snake_case=True						,				_snake_case=99						,				_snake_case=32						,				_snake_case=32						,				_snake_case=2						,				_snake_case=4						,				_snake_case=37						,				_snake_case=0.1						,				_snake_case=0.1						,				_snake_case=512						,				_snake_case=0.02						,				_snake_case=0						,				_snake_case=None						,				):



									"""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 							snake_case   (							self		):



									"""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(_snake_case		):
																			_lowerCAmelCase						=    1
																			_lowerCAmelCase						=    0

									_lowerCAmelCase						=    self.get_config()

									return config, input_ids, tf.convert_to_tensor(_snake_case		)




				def 							snake_case   (							self		):



									"""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 							snake_case   (							self						,				_snake_case						,				_snake_case						,				_snake_case		):



									"""simple docstring"""





									_lowerCAmelCase						=    TFBlipTextModel(config=_snake_case		)
									_lowerCAmelCase						=    model(_snake_case						,				attention_mask=_snake_case						,				training=_snake_case		)
									_lowerCAmelCase						=    model(_snake_case						,				training=_snake_case		)
									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 							snake_case   (							self		):



									"""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 (     lowerCamelCase__       ,						unittest.TestCase       ):
				__lowerCamelCase =				(TFBlipTextModel,) if is_tf_available() else ()
				__lowerCamelCase =				False
				__lowerCamelCase =				False
				__lowerCamelCase =				False




				def 							snake_case   (							self		):



									"""simple docstring"""





									_lowerCAmelCase						=    BlipTextModelTester(self		)
									_lowerCAmelCase						=    ConfigTester(self						,				config_class=_snake_case						,				hidden_size=37		)




				def 							snake_case   (							self		):



									"""simple docstring"""





									self.config_tester.run_common_tests()




				def 							snake_case   (							self		):



									"""simple docstring"""





									_lowerCAmelCase						=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_snake_case		)




				def 							snake_case   (							self		):



									"""simple docstring"""





									pass




				def 							snake_case   (							self		):



									"""simple docstring"""





									pass




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



									"""simple docstring"""





									pass




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



									"""simple docstring"""





									pass




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



									"""simple docstring"""





									pass




				@slow
				def 							snake_case   (							self		):



									"""simple docstring"""





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




				def 							snake_case   (							self						,				_snake_case=True		):



									"""simple docstring"""





									super().test_pt_tf_model_equivalence(allow_missing_keys=_snake_case		)




"""simple docstring"""






def   a_						(					lowerCamelCase       ):
				return str(lowerCamelCase       ) == str(lowerCamelCase       )[::-1]



def   a_						(					lowerCamelCase       ):
				return int(lowerCamelCase       ) + int(str(lowerCamelCase       )[::-1]       )



def   a_						(					lowerCamelCase = 1_0_0_0_0       ):
				UpperCAmelCase__             =							[]
				for num in range(1					,			lowerCamelCase       ):
								UpperCAmelCase__             =							0
								UpperCAmelCase__             =							num
								while iterations < 5_0:
												UpperCAmelCase__             =							sum_reverse(lowerCamelCase       )
												iterations += 1
												if is_palindrome(lowerCamelCase       ):
																break
								else:
												lychrel_nums.append(lowerCamelCase       )
				return len(lowerCamelCase       )


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



