"""simple docstring"""






import unittest

import numpy as np

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

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
						import jax.numpy as jnp

						from transformers.models.albert.modeling_flax_albert import (
						    FlaxAlbertForMaskedLM,
						    FlaxAlbertForMultipleChoice,
						    FlaxAlbertForPreTraining,
						    FlaxAlbertForQuestionAnswering,
						    FlaxAlbertForSequenceClassification,
						    FlaxAlbertForTokenClassification,
						    FlaxAlbertModel,
						)

class lowerCamelCase		(unittest.TestCase      ):






					'''simple docstring'''


					def __init__(						self			:				Optional[Any]   , _snake_case			:				List[Any]   , _snake_case			:				Union[str, Any]=13   , _snake_case			:				Union[str, Any]=7   , _snake_case			:				Optional[int]=True   , _snake_case			:				Optional[Any]=True   , _snake_case			:				Optional[int]=True   , _snake_case			:				Any=True   , _snake_case			:				List[str]=99   , _snake_case			:				str=32   , _snake_case			:				Optional[int]=5   , _snake_case			:				List[str]=4   , _snake_case			:				Any=37   , _snake_case			:				Dict="gelu"   , _snake_case			:				List[str]=0.1   , _snake_case			:				Any=0.1   , _snake_case			:				int=512   , _snake_case			:				Any=16   , _snake_case			:				List[str]=2   , _snake_case			:				Dict=0.02   , _snake_case			:				List[Any]=4   , )							->       Tuple:
									SCREAMING_SNAKE_CASE__		  =				parent
									SCREAMING_SNAKE_CASE__		  =				batch_size
									SCREAMING_SNAKE_CASE__		  =				seq_length
									SCREAMING_SNAKE_CASE__		  =				is_training
									SCREAMING_SNAKE_CASE__		  =				use_attention_mask
									SCREAMING_SNAKE_CASE__		  =				use_token_type_ids
									SCREAMING_SNAKE_CASE__		  =				use_labels
									SCREAMING_SNAKE_CASE__		  =				vocab_size
									SCREAMING_SNAKE_CASE__		  =				hidden_size
									SCREAMING_SNAKE_CASE__		  =				num_hidden_layers
									SCREAMING_SNAKE_CASE__		  =				num_attention_heads
									SCREAMING_SNAKE_CASE__		  =				intermediate_size
									SCREAMING_SNAKE_CASE__		  =				hidden_act
									SCREAMING_SNAKE_CASE__		  =				hidden_dropout_prob
									SCREAMING_SNAKE_CASE__		  =				attention_probs_dropout_prob
									SCREAMING_SNAKE_CASE__		  =				max_position_embeddings
									SCREAMING_SNAKE_CASE__		  =				type_vocab_size
									SCREAMING_SNAKE_CASE__		  =				type_sequence_label_size
									SCREAMING_SNAKE_CASE__		  =				initializer_range
									SCREAMING_SNAKE_CASE__		  =				num_choices



					def 			lowerCAmelCase_					(						self			:				Any		)							->       List[str]:
									SCREAMING_SNAKE_CASE__		  =				ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size		)

									SCREAMING_SNAKE_CASE__		  =				None
									if self.use_attention_mask:
													SCREAMING_SNAKE_CASE__		  =				random_attention_mask([self.batch_size, self.seq_length]		)

									SCREAMING_SNAKE_CASE__		  =				None
									if self.use_token_type_ids:
													SCREAMING_SNAKE_CASE__		  =				ids_tensor([self.batch_size, self.seq_length]   , self.type_vocab_size		)

									SCREAMING_SNAKE_CASE__		  =				AlbertConfig(
									    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=_snake_case   , initializer_range=self.initializer_range   , )

									return config, input_ids, token_type_ids, attention_mask



					def 			lowerCAmelCase_					(						self			:				Union[str, Any]		)							->       Union[str, Any]:
									SCREAMING_SNAKE_CASE__		  =				self.prepare_config_and_inputs()
									SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				config_and_inputs
									SCREAMING_SNAKE_CASE__		  =				{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": attention_mask}
									return config, inputs_dict



@require_flax
class lowerCamelCase		(_SCREAMING_SNAKE_CASE    ,    unittest.TestCase      ):






					'''simple docstring'''


					a   	=		(
					    (
					        FlaxAlbertModel,
					        FlaxAlbertForPreTraining,
					        FlaxAlbertForMaskedLM,
					        FlaxAlbertForMultipleChoice,
					        FlaxAlbertForQuestionAnswering,
					        FlaxAlbertForSequenceClassification,
					        FlaxAlbertForTokenClassification,
					        FlaxAlbertForQuestionAnswering,
					    )
					    if is_flax_available()
					    else ()
					)



					def 			lowerCAmelCase_					(						self			:				int		)							->       List[Any]:
									SCREAMING_SNAKE_CASE__		  =				FlaxAlbertModelTester(self		)



					@slow
					def 			lowerCAmelCase_					(						self			:				int		)							->       List[Any]:
									for model_class_name in self.all_model_classes:
													SCREAMING_SNAKE_CASE__		  =				model_class_name.from_pretrained("albert-base-v2"		)
													SCREAMING_SNAKE_CASE__		  =				model(np.ones((1, 1)		)		)
													self.assertIsNotNone(_snake_case		)



@require_flax
class lowerCamelCase		(unittest.TestCase      ):






					'''simple docstring'''


					@slow
					def 			lowerCAmelCase_					(						self			:				Tuple		)							->       Any:
									SCREAMING_SNAKE_CASE__		  =				FlaxAlbertModel.from_pretrained("albert-base-v2"		)
									SCREAMING_SNAKE_CASE__		  =				np.array([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]		)
									SCREAMING_SNAKE_CASE__		  =				np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]		)
									SCREAMING_SNAKE_CASE__		  =				model(_snake_case   , attention_mask=_snake_case		)[0]
									SCREAMING_SNAKE_CASE__		  =				(1, 11, 768)
									self.assertEqual(output.shape   , _snake_case		)
									SCREAMING_SNAKE_CASE__		  =				np.array(
									    [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]		)

									self.assertTrue(jnp.allclose(output[:, 1:4, 1:4]   , _snake_case   , atol=1e-4		)		)





"""simple docstring"""






from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_A   					=    {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']}


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_A   					=    [
						    'VAN_PRETRAINED_MODEL_ARCHIVE_LIST',
						    'VanForImageClassification',
						    'VanModel',
						    'VanPreTrainedModel',
						]

if TYPE_CHECKING:
						from .configuration_van import VAN_PRETRAINED_CONFIG_ARCHIVE_MAP, VanConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_van import (
												    VAN_PRETRAINED_MODEL_ARCHIVE_LIST,
												    VanForImageClassification,
												    VanModel,
												    VanPreTrainedModel,
												)

else:
						import sys

						_A   					=    _LazyModule(__name__, globals()['__file__'], _import_structure)




