



import unittest

import numpy as np

from transformers import BertConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
							from transformers.models.bert.modeling_flax_bert import (
							    FlaxBertForMaskedLM,
							    FlaxBertForMultipleChoice,
							    FlaxBertForNextSentencePrediction,
							    FlaxBertForPreTraining,
							    FlaxBertForQuestionAnswering,
							    FlaxBertForSequenceClassification,
							    FlaxBertForTokenClassification,
							    FlaxBertModel,
							)



class 	lowerCamelCase__      (							unittest.TestCase):




		'''simple docstring'''



		def __init__(self		,__lowerCamelCase		,__lowerCamelCase=13		,__lowerCamelCase=7		,__lowerCamelCase=True		,__lowerCamelCase=True		,__lowerCamelCase=True		,__lowerCamelCase=True		,__lowerCamelCase=99		,__lowerCamelCase=32		,__lowerCamelCase=5		,__lowerCamelCase=4		,__lowerCamelCase=37		,__lowerCamelCase="gelu"		,__lowerCamelCase=0.1		,__lowerCamelCase=0.1		,__lowerCamelCase=5_12		,__lowerCamelCase=16		,__lowerCamelCase=2		,__lowerCamelCase=0.02		,__lowerCamelCase=4		,)					->      Tuple:

						"""simple docstring"""






						lowerCAmelCase__					:    Dict												=					parent
						lowerCAmelCase__					:    int												=					batch_size
						lowerCAmelCase__					:    int												=					seq_length
						lowerCAmelCase__					:    Optional[int]												=					is_training
						lowerCAmelCase__					:    Tuple												=					use_attention_mask
						lowerCAmelCase__					:    Union[str, Any]												=					use_token_type_ids
						lowerCAmelCase__					:    Union[str, Any]												=					use_labels
						lowerCAmelCase__					:    Optional[int]												=					vocab_size
						lowerCAmelCase__					:    int												=					hidden_size
						lowerCAmelCase__					:    List[Any]												=					num_hidden_layers
						lowerCAmelCase__					:    str												=					num_attention_heads
						lowerCAmelCase__					:    Union[str, Any]												=					intermediate_size
						lowerCAmelCase__					:    List[str]												=					hidden_act
						lowerCAmelCase__					:    Optional[Any]												=					hidden_dropout_prob
						lowerCAmelCase__					:    List[str]												=					attention_probs_dropout_prob
						lowerCAmelCase__					:    Union[str, Any]												=					max_position_embeddings
						lowerCAmelCase__					:    List[Any]												=					type_vocab_size
						lowerCAmelCase__					:    Dict												=					type_sequence_label_size
						lowerCAmelCase__					:    Dict												=					initializer_range
						lowerCAmelCase__					:    Any												=					num_choices



		def 		lowerCAmelCase__				(self			)					->      Optional[int]:

						"""simple docstring"""






						lowerCAmelCase__					:    Optional[Any]												=					ids_tensor([self.batch_size, self.seq_length]		,self.vocab_size			)

						lowerCAmelCase__					:    str												=					None
						if self.use_attention_mask:
										lowerCAmelCase__					:    Optional[int]												=					random_attention_mask([self.batch_size, self.seq_length]			)

						lowerCAmelCase__					:    Union[str, Any]												=					None
						if self.use_token_type_ids:
										lowerCAmelCase__					:    Optional[int]												=					ids_tensor([self.batch_size, self.seq_length]		,self.type_vocab_size			)

						lowerCAmelCase__					:    int												=					BertConfig(
						    vocab_size=self.vocab_size		,hidden_size=self.hidden_size		,num_hidden_layers=self.num_hidden_layers		,num_attention_heads=self.num_attention_heads		,intermediate_size=self.intermediate_size		,hidden_act=self.hidden_act		,hidden_dropout_prob=self.hidden_dropout_prob		,attention_probs_dropout_prob=self.attention_probs_dropout_prob		,max_position_embeddings=self.max_position_embeddings		,type_vocab_size=self.type_vocab_size		,is_decoder=__lowerCamelCase		,initializer_range=self.initializer_range		,)

						return config, input_ids, token_type_ids, attention_mask



		def 		lowerCAmelCase__				(self			)					->      Tuple:

						"""simple docstring"""






						lowerCAmelCase__					:    Union[str, Any]												=					self.prepare_config_and_inputs()
						lowerCAmelCase__						,		lowerCAmelCase__						,		lowerCAmelCase__						,		lowerCAmelCase__					:    List[Any]												=					config_and_inputs
						lowerCAmelCase__					:    Tuple												=					{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
						return config, inputs_dict



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

						"""simple docstring"""






						lowerCAmelCase__					:    Dict												=					self.prepare_config_and_inputs()
						lowerCAmelCase__						,		lowerCAmelCase__						,		lowerCAmelCase__						,		lowerCAmelCase__					:    Union[str, Any]												=					config_and_inputs

						lowerCAmelCase__					:    str												=					True
						lowerCAmelCase__					:    List[str]												=					floats_tensor([self.batch_size, self.seq_length, self.hidden_size]			)
						lowerCAmelCase__					:    Optional[Any]												=					ids_tensor([self.batch_size, self.seq_length]		,vocab_size=2			)

						return (
						    config,
						    input_ids,
						    attention_mask,
						    encoder_hidden_states,
						    encoder_attention_mask,
						)



@require_flax
class 	lowerCamelCase__      (							lowerCamelCase__				,    unittest.TestCase):




		'''simple docstring'''



		snake_case_     =True

		snake_case_     =(
		    (
		        FlaxBertModel,
		        FlaxBertForPreTraining,
		        FlaxBertForMaskedLM,
		        FlaxBertForMultipleChoice,
		        FlaxBertForQuestionAnswering,
		        FlaxBertForNextSentencePrediction,
		        FlaxBertForSequenceClassification,
		        FlaxBertForTokenClassification,
		        FlaxBertForQuestionAnswering,
		    )
		    if is_flax_available()
		    else ()
		)



		def 		lowerCAmelCase__				(self			)					->      Any:

						"""simple docstring"""






						lowerCAmelCase__					:    Union[str, Any]												=					FlaxBertModelTester(self			)



		@slow
		def 		lowerCAmelCase__				(self			)					->      List[Any]:

						"""simple docstring"""






						lowerCAmelCase__					:    Tuple												=					FlaxBertModel.from_pretrained('''bert-base-cased'''			)
						lowerCAmelCase__					:    List[str]												=					model(np.ones((1, 1)			)			)
						self.assertIsNotNone(__lowerCamelCase			)






from typing import TYPE_CHECKING

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


__snake_case    :		Optional[int]  ={
    'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'],
    'processing_vision_text_dual_encoder': ['VisionTextDualEncoderProcessor'],
}


try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__snake_case    :		int  =['VisionTextDualEncoderModel']


try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__snake_case    :		List[str]  =['FlaxVisionTextDualEncoderModel']

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__snake_case    :		Tuple  =['TFVisionTextDualEncoderModel']


if TYPE_CHECKING:
							from .configuration_vision_text_dual_encoder import VisionTextDualEncoderConfig
							from .processing_vision_text_dual_encoder import VisionTextDualEncoderProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_vision_text_dual_encoder import VisionTextDualEncoderModel

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_vision_text_dual_encoder import FlaxVisionTextDualEncoderModel

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_vision_text_dual_encoder import TFVisionTextDualEncoderModel


else:
							import sys

							__snake_case    :		str  =_LazyModule(__name__, globals()['__file__'], _import_structure)

