



"""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       _a  :



			def __init__(			self							:				Optional[int]   ,	_lowercase							:				str   ,	_lowercase							:				int=12   ,	_lowercase							:				Optional[Any]=7   ,	_lowercase							:				Any=True   ,	_lowercase							:				Optional[int]=True   ,	_lowercase							:				List[Any]=True   ,	_lowercase							:				List[Any]=99   ,	_lowercase							:				Optional[int]=32   ,	_lowercase							:				List[Any]=32   ,	_lowercase							:				List[Any]=2   ,	_lowercase							:				Dict=4   ,	_lowercase							:				Optional[Any]=37   ,	_lowercase							:				int=0.1   ,	_lowercase							:				str=0.1   ,	_lowercase							:				Tuple=512   ,	_lowercase							:				Optional[Any]=0.02   ,	_lowercase							:				Dict=0   ,	_lowercase							:				List[str]=None   ,	)							->					List[Any]:
									snake_case   :			Tuple						    = parent
									snake_case   :			int						    = batch_size
									snake_case   :			Union[str, Any]						    = seq_length
									snake_case   :			str						    = is_training
									snake_case   :			int						    = use_input_mask
									snake_case   :			Optional[Any]						    = use_labels
									snake_case   :			Optional[int]						    = vocab_size
									snake_case   :			List[Any]						    = hidden_size
									snake_case   :			List[Any]						    = projection_dim
									snake_case   :			List[str]						    = num_hidden_layers
									snake_case   :			Optional[Any]						    = num_attention_heads
									snake_case   :			Dict						    = intermediate_size
									snake_case   :			str						    = dropout
									snake_case   :			Union[str, Any]						    = attention_dropout
									snake_case   :			List[Any]						    = max_position_embeddings
									snake_case   :			str						    = initializer_range
									snake_case   :			Union[str, Any]						    = scope
									snake_case   :			int						    = bos_token_id



			def 				__lowercase					(			self							:				Optional[Any]		)							->					Optional[int]:
									snake_case   :			List[Any]						    = ids_tensor([self.batch_size, self.seq_length]   ,	self.vocab_size		)

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

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

									snake_case   :			Union[str, Any]						    = self.get_config()

									return config, input_ids, tf.convert_to_tensor(_lowercase		)



			def 				__lowercase					(			self							:				int		)							->					str:
									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							:				Dict   ,	_lowercase							:				Optional[Any]   ,	_lowercase							:				Optional[int]   ,	_lowercase							:				List[str]		)							->					List[Any]:
									snake_case   :			Optional[int]						    = TFBlipTextModel(config=_lowercase		)
									snake_case   :			Optional[int]						    = model(_lowercase   ,	attention_mask=_lowercase   ,	training=_lowercase		)
									snake_case   :			Dict						    = model(_lowercase   ,	training=_lowercase		)
									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							:				List[str]		)							->					Tuple:
									snake_case   :			str						    = self.prepare_config_and_inputs()
									snake_case    ,			snake_case    ,			snake_case   :			str						    = config_and_inputs
									snake_case   :			Optional[int]						    = {"input_ids": input_ids, "attention_mask": input_mask}
									return config, inputs_dict



@require_tf
class       _a  ( SCREAMING_SNAKE_CASE__     ,	unittest.TestCase):
			__magic_name__     					=     (TFBlipTextModel,) if is_tf_available() else ()
			__magic_name__     					=     False
			__magic_name__     					=     False
			__magic_name__     					=     False



			def 				__lowercase					(			self							:				Any		)							->					Union[str, Any]:
									snake_case   :			List[Any]						    = BlipTextModelTester(self		)
									snake_case   :			str						    = ConfigTester(self   ,	config_class=_lowercase   ,	hidden_size=37		)



			def 				__lowercase					(			self							:				List[str]		)							->					Optional[Any]:
									self.config_tester.run_common_tests()



			def 				__lowercase					(			self							:				str		)							->					Tuple:
									snake_case   :			int						    = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_lowercase		)



			def 				__lowercase					(			self							:				List[str]		)							->					Dict:
									pass



			def 				__lowercase					(			self							:				int		)							->					Optional[Any]:
									pass



			@unittest.skip(reason="Blip does not use inputs_embeds"		)
			def 				__lowercase					(			self							:				Dict		)							->					Any:
									pass



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



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



			@slow
			def 				__lowercase					(			self							:				Dict		)							->					Tuple:
									for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															snake_case   :			Optional[int]						    = TFBlipTextModel.from_pretrained(_lowercase		)
															self.assertIsNotNone(_lowercase		)



			def 				__lowercase					(			self							:				Dict   ,	_lowercase							:				Optional[int]=True		)							->					List[str]:
									super().test_pt_tf_model_equivalence(allow_missing_keys=_lowercase		)








"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A		=						{'configuration_vit': ['VIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTConfig', 'ViTOnnxConfig']}

try:
			if not is_vision_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			A		=						['ViTFeatureExtractor']
			A		=						['ViTImageProcessor']

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			A		=						[
			    'VIT_PRETRAINED_MODEL_ARCHIVE_LIST',
			    'ViTForImageClassification',
			    'ViTForMaskedImageModeling',
			    'ViTModel',
			    'ViTPreTrainedModel',
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			A		=						[
			    'TFViTForImageClassification',
			    'TFViTModel',
			    'TFViTPreTrainedModel',
			]

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			A		=						[
			    'FlaxViTForImageClassification',
			    'FlaxViTModel',
			    'FlaxViTPreTrainedModel',
			]

if TYPE_CHECKING:
			from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig, ViTOnnxConfig

			try:
						if not is_vision_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .feature_extraction_vit import ViTFeatureExtractor
						from .image_processing_vit import ViTImageProcessor

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_vit import (
						    VIT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    ViTForImageClassification,
						    ViTForMaskedImageModeling,
						    ViTModel,
						    ViTPreTrainedModel,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_vit import TFViTForImageClassification, TFViTModel, TFViTPreTrainedModel

			try:
						if not is_flax_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel, FlaxViTPreTrainedModel


else:
			import sys

			A		=						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



