


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

		"""simple docstring"""

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

							'''simple docstring'''


							UpperCamelCase__       :str							 =			parent
							UpperCamelCase__       :Any							 =			batch_size
							UpperCamelCase__       :Tuple							 =			seq_length
							UpperCamelCase__       :int							 =			is_training
							UpperCamelCase__       :Optional[int]							 =			use_input_mask
							UpperCamelCase__       :Any							 =			use_labels
							UpperCamelCase__       :Optional[int]							 =			vocab_size
							UpperCamelCase__       :int							 =			hidden_size
							UpperCamelCase__       :Optional[int]							 =			projection_dim
							UpperCamelCase__       :str							 =			num_hidden_layers
							UpperCamelCase__       :Union[str, Any]							 =			num_attention_heads
							UpperCamelCase__       :Any							 =			intermediate_size
							UpperCamelCase__       :int							 =			dropout
							UpperCamelCase__       :Tuple							 =			attention_dropout
							UpperCamelCase__       :List[str]							 =			max_position_embeddings
							UpperCamelCase__       :Optional[int]							 =			initializer_range
							UpperCamelCase__       :Optional[Any]							 =			scope
							UpperCamelCase__       :List[str]							 =			bos_token_id




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :List[str]							 =			ids_tensor([self.batch_size, self.seq_length]   ,       self.vocab_size							)

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

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

							UpperCamelCase__       :int							 =			self.get_config()

							return config, input_ids, tf.convert_to_tensor(UpperCamelCase_							)




		def    lowerCAmelCase__    (		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    lowerCAmelCase__    (		self   ,       UpperCamelCase_   ,       UpperCamelCase_   ,       UpperCamelCase_							):

							'''simple docstring'''


							UpperCamelCase__       :Tuple							 =			TFBlipTextModel(config=UpperCamelCase_							)
							UpperCamelCase__       :Optional[int]							 =			model(UpperCamelCase_   ,       attention_mask=UpperCamelCase_   ,       training=UpperCamelCase_							)
							UpperCamelCase__       :Any							 =			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    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Optional[int]							 =			self.prepare_config_and_inputs()
							UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       :Any							 =			config_and_inputs
							UpperCamelCase__       :Tuple							 =			{'''input_ids''': input_ids, '''attention_mask''': input_mask}
							return config, inputs_dict



@require_tf
class        lowercase     (							A__     ,		unittest.TestCase ):

		"""simple docstring"""

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




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Tuple							 =			BlipTextModelTester(self							)
							UpperCamelCase__       :Dict							 =			ConfigTester(self   ,       config_class=UpperCamelCase_   ,       hidden_size=37							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							self.config_tester.run_common_tests()




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Any							 =			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*UpperCamelCase_							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							pass




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							pass




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

							'''simple docstring'''


							pass




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

							'''simple docstring'''


							pass




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

							'''simple docstring'''


							pass




		@slow
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


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




		def    lowerCAmelCase__    (		self   ,       UpperCamelCase_=True							):

							'''simple docstring'''


							super().test_pt_tf_model_equivalence(allow_missing_keys=UpperCamelCase_							)



'''simple docstring'''
from __future__ import annotations

import math


def       a				(      __a       )  ->     bool:



					'''simple docstring'''






					if 1 < number < 4:
										# 2 and 3 are primes
										return True
					elif number < 2 or number % 2 == 0 or number % 3 == 0:
										# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
										return False

					# All primes number are in format of 6k +/- 1
					for i in range(5			, int(math.sqrt(__a       ) + 1       )			, 6       ):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True


def       a				(      __a       )  ->     list[int]:



					'''simple docstring'''






					UpperCamelCase__       :List[Any]							 =			str(__a       )
					UpperCamelCase__       :Dict							 =			[n]
					for i in range(1			, len(__a       )       ):
										list_nums.append(int(str_num[i:]       )       )
										list_nums.append(int(str_num[:-i]       )       )
					return list_nums


def       a				(      __a       )  ->     bool:



					'''simple docstring'''






					if len(str(__a       )       ) > 3:
										if not is_prime(int(str(__a       )[-3:]       )       ) or not is_prime(int(str(__a       )[:3]       )       ):
															return False
					return True


def       a				(      __a = 11       )  ->     list[int]:



					'''simple docstring'''






					UpperCamelCase__       :list[int]							 =			[]
					UpperCamelCase__       :int							 =			13
					while len(__a       ) != count:
										if validate(__a       ):
															UpperCamelCase__       :Optional[int]							 =			list_truncated_nums(__a       )
															if all(is_prime(__a       ) for i in list_nums       ):
																				list_truncated_primes.append(__a       )
										num += 2
					return list_truncated_primes


def       a				(      )  ->     int:



					'''simple docstring'''






					return sum(compute_truncated_primes(11       )       )


if __name__ == "__main__":
		print(F"""{sum(compute_truncated_primes(11)) = }""")