

import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import is_torch_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask


if is_torch_available():
				import torch

				from transformers import BlipTextModel
				from transformers.models.blip.modeling_blip import BLIP_PRETRAINED_MODEL_ARCHIVE_LIST

class   __UpperCamelCase			:




	def __init__(						self		:  int						,		lowerCAmelCase		:  Optional[Any]						,		lowerCAmelCase		:  int=12						,		lowerCAmelCase		:  Optional[Any]=7						,		lowerCAmelCase		:  Dict=True						,		lowerCAmelCase		:  int=True						,		lowerCAmelCase		:  List[str]=True						,		lowerCAmelCase		:  List[Any]=99						,		lowerCAmelCase		:  Dict=32						,		lowerCAmelCase		:  Union[str, Any]=32						,		lowerCAmelCase		:  List[Any]=5						,		lowerCAmelCase		:  str=4						,		lowerCAmelCase		:  Any=37						,		lowerCAmelCase		:  Union[str, Any]=0.1						,		lowerCAmelCase		:  int=0.1						,		lowerCAmelCase		:  Tuple=512						,		lowerCAmelCase		:  Optional[int]=0.02						,		lowerCAmelCase		:  str=0						,		lowerCAmelCase		:  Union[str, Any]=None						,		):


		'''simple docstring'''







		UpperCAmelCase_				 =	parent
		UpperCAmelCase_				 =	batch_size
		UpperCAmelCase_				 =	seq_length
		UpperCAmelCase_				 =	is_training
		UpperCAmelCase_				 =	use_input_mask
		UpperCAmelCase_				 =	use_labels
		UpperCAmelCase_				 =	vocab_size
		UpperCAmelCase_				 =	hidden_size
		UpperCAmelCase_				 =	projection_dim
		UpperCAmelCase_				 =	num_hidden_layers
		UpperCAmelCase_				 =	num_attention_heads
		UpperCAmelCase_				 =	intermediate_size
		UpperCAmelCase_				 =	dropout
		UpperCAmelCase_				 =	attention_dropout
		UpperCAmelCase_				 =	max_position_embeddings
		UpperCAmelCase_				 =	initializer_range
		UpperCAmelCase_				 =	scope
		UpperCAmelCase_				 =	bos_token_id




	def 					__A    (						self		:  Any							):


		'''simple docstring'''







		UpperCAmelCase_				 =	ids_tensor([self.batch_size, self.seq_length]						,		self.vocab_size							)

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

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

		UpperCAmelCase_				 =	self.get_config()

		return config, input_ids, input_mask




	def 					__A    (						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 					__A    (						self		:  str						,		lowerCAmelCase		:  Optional[Any]						,		lowerCAmelCase		:  Optional[int]						,		lowerCAmelCase		:  List[str]							):


		'''simple docstring'''







		UpperCAmelCase_				 =	BlipTextModel(config=__lowerCamelCase							)
		model.to(__lowerCamelCase							)
		model.eval()
		with torch.no_grad():
			UpperCAmelCase_				 =	model(__lowerCamelCase						,		attention_mask=__lowerCamelCase							)
			UpperCAmelCase_				 =	model(__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 					__A    (						self		:  str							):


		'''simple docstring'''







		UpperCAmelCase_				 =	self.prepare_config_and_inputs()
		UpperCAmelCase_				 =	config_and_inputs
		UpperCAmelCase_				 =	{"input_ids": input_ids, "attention_mask": input_mask}
		return config, inputs_dict


@require_torch
class   __UpperCamelCase			(    __lowercase   ,   unittest.TestCase  ):
	SCREAMING_SNAKE_CASE__			 =   (BlipTextModel,) if is_torch_available() else ()
	SCREAMING_SNAKE_CASE__			 =   False
	SCREAMING_SNAKE_CASE__			 =   False
	SCREAMING_SNAKE_CASE__			 =   False




	def 					__A    (						self		:  Optional[Any]							):


		'''simple docstring'''







		UpperCAmelCase_				 =	BlipTextModelTester(self							)
		UpperCAmelCase_				 =	ConfigTester(self						,		config_class=__lowerCamelCase						,		hidden_size=37							)




	def 					__A    (						self		:  List[Any]							):


		'''simple docstring'''







		self.config_tester.run_common_tests()




	def 					__A    (						self		:  List[str]							):


		'''simple docstring'''







		UpperCAmelCase_				 =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_model(*__lowerCamelCase							)




	def 					__A    (						self		:  List[str]							):


		'''simple docstring'''







		pass




	def 					__A    (						self		:  Dict							):


		'''simple docstring'''







		pass




	@unittest.skip(reason="Blip does not use inputs_embeds"							)
	def 					__A    (						self		:  List[str]							):


		'''simple docstring'''







		pass




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


		'''simple docstring'''







		pass




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


		'''simple docstring'''







		pass




	@slow
	def 					__A    (						self		:  Union[str, Any]							):


		'''simple docstring'''







		for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
			UpperCAmelCase_				 =	BlipTextModel.from_pretrained(__lowerCamelCase							)
			self.assertIsNotNone(__lowerCamelCase							)




	def 					__A    (						self		:  Dict							):


		'''simple docstring'''







		super().test_pt_tf_model_equivalence(allow_missing_keys=__lowerCamelCase							)






from itertools import permutations






def 			lowerCamelCase__	():
     _SCREAMING_SNAKE_CASE				:		Dict  			=							list(map("".join,				permutations("0123456789"		)		)		)
     return result[999999]


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