
'''simple docstring'''







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					):






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


											"""simple docstring"""





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






					def      _snake_case   (       self		):


											"""simple docstring"""





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

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

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

											lowercase_     :					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=__SCREAMING_SNAKE_CASE    ,							initializer_range=self.initializer_range    ,							)

											return config, input_ids, token_type_ids, attention_mask






					def      _snake_case   (       self		):


											"""simple docstring"""





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






					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					Any													=	self.prepare_config_and_inputs()
											lowercase_						,			lowercase_						,			lowercase_						,			lowercase_     :					str													=	config_and_inputs

											lowercase_     :					str													=	True
											lowercase_     :					Optional[Any]													=	floats_tensor([self.batch_size, self.seq_length, self.hidden_size]		)
											lowercase_     :					str													=	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					):
					lowerCAmelCase_					       =					True

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






					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					int													=	FlaxBertModelTester(self		)






					@slow
					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					Dict													=	FlaxBertModel.from_pretrained('''bert-base-cased'''		)
											lowercase_     :					Dict													=	model(np.ones((1, 1)		)		)
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE		)





'''simple docstring'''







def  snake_case_		(    __SCREAMING_SNAKE_CASE :			str							):



						"""simple docstring"""





						return [
						    txt[:a] + txt[a].upper() + txt[a + 1 :]
						    for a in range(len(__SCREAMING_SNAKE_CASE							)							)
						    if txt[a].isalpha()
						]


if __name__ == "__main__":
							__import__("doctest").testmod()



