
'''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 						__UpperCAmelCase      (					unittest.TestCase						):


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





								"""simple docstring"""






								_snake_case   						=		parent
								_snake_case   						=		batch_size
								_snake_case   						=		seq_length
								_snake_case   						=		is_training
								_snake_case   						=		use_attention_mask
								_snake_case   						=		use_token_type_ids
								_snake_case   						=		use_labels
								_snake_case   						=		vocab_size
								_snake_case   						=		hidden_size
								_snake_case   						=		num_hidden_layers
								_snake_case   						=		num_attention_heads
								_snake_case   						=		intermediate_size
								_snake_case   						=		hidden_act
								_snake_case   						=		hidden_dropout_prob
								_snake_case   						=		attention_probs_dropout_prob
								_snake_case   						=		max_position_embeddings
								_snake_case   						=		type_vocab_size
								_snake_case   						=		type_sequence_label_size
								_snake_case   						=		initializer_range
								_snake_case   						=		num_choices


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






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

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

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

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





								"""simple docstring"""






								_snake_case   						=		self.prepare_config_and_inputs()
								_snake_case						, _snake_case						, _snake_case						, _snake_case   						=		config_and_inputs
								_snake_case   						=		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': attention_mask}
								return config, inputs_dict




							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		self.prepare_config_and_inputs()
								_snake_case						, _snake_case						, _snake_case						, _snake_case   						=		config_and_inputs

								_snake_case   						=		True
								_snake_case   						=		floats_tensor([self.batch_size, self.seq_length, self.hidden_size]  )
								_snake_case   						=		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 						__UpperCAmelCase      (					_lowerCamelCase						,   unittest.TestCase						):
							__lowercase      		=       True

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


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		FlaxBertModelTester(self  )




							@slow
							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		FlaxBertModel.from_pretrained('bert-base-cased'  )
								_snake_case   						=		model(np.ones((1, 1)  )  )
								self.assertIsNotNone(lowerCAmelCase_  )



'''simple docstring'''







def 				SCREAMING_SNAKE_CASE__	(   __A	)       ->	bool:
	return number & 1 == 0


if __name__ == "__main__":
					import doctest

					doctest.testmod()

