



"""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      A__  (    unittest.TestCase				):




	'''simple docstring'''





	def __init__(	self:						str			,     _SCREAMING_SNAKE_CASE:						List[str]			,     _SCREAMING_SNAKE_CASE:						Any=13			,     _SCREAMING_SNAKE_CASE:						Optional[int]=7			,     _SCREAMING_SNAKE_CASE:						str=True			,     _SCREAMING_SNAKE_CASE:						Any=True			,     _SCREAMING_SNAKE_CASE:						Dict=True			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=True			,     _SCREAMING_SNAKE_CASE:						List[str]=99			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=32			,     _SCREAMING_SNAKE_CASE:						List[str]=5			,     _SCREAMING_SNAKE_CASE:						str=4			,     _SCREAMING_SNAKE_CASE:						int=37			,     _SCREAMING_SNAKE_CASE:						List[str]="gelu"			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=0.1			,     _SCREAMING_SNAKE_CASE:						str=0.1			,     _SCREAMING_SNAKE_CASE:						Optional[int]=512			,     _SCREAMING_SNAKE_CASE:						List[str]=16			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=2			,     _SCREAMING_SNAKE_CASE:						Optional[int]=0.02			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=4			,     )							->			Optional[Any]:

				"""simple docstring"""

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

	def 				_SCREAMING_SNAKE_CASE  (	self:						Tuple)							->			Dict:

				"""simple docstring"""

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

				__lowerCAmelCase :    Union[str, Any]				=			None
				if self.use_attention_mask:
							__lowerCAmelCase :    Any				=			random_attention_mask([self.batch_size, self.seq_length])

				__lowerCAmelCase :    List[str]				=			None
				if self.use_token_type_ids:
							__lowerCAmelCase :    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=_SCREAMING_SNAKE_CASE			,     initializer_range=self.initializer_range			,     )

				return config, input_ids, token_type_ids, attention_mask

	def 				_SCREAMING_SNAKE_CASE  (	self:						List[Any])							->			int:

				"""simple docstring"""

				__lowerCAmelCase :    List[str]				=			self.prepare_config_and_inputs()
				__lowerCAmelCase		,      __lowerCAmelCase		,      __lowerCAmelCase		,      __lowerCAmelCase :    List[str]				=			config_and_inputs
				__lowerCAmelCase :    Dict				=			{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": attention_mask}
				return config, inputs_dict







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

				"""simple docstring"""

				__lowerCAmelCase :    int				=			self.prepare_config_and_inputs()
				__lowerCAmelCase		,      __lowerCAmelCase		,      __lowerCAmelCase		,      __lowerCAmelCase :    str				=			config_and_inputs

				__lowerCAmelCase :    Tuple				=			True
				__lowerCAmelCase :    List[str]				=			floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
				__lowerCAmelCase :    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      A__  (    __SCREAMING_SNAKE_CASE    ,						unittest.TestCase				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      True

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

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

				"""simple docstring"""

				__lowerCAmelCase :    Optional[Any]				=			FlaxBertModelTester(self)







	@slow
	def 				_SCREAMING_SNAKE_CASE  (	self:						Union[str, Any])							->			Dict:

				"""simple docstring"""

				__lowerCAmelCase :    List[str]				=			FlaxBertModel.from_pretrained("bert-base-cased")
				__lowerCAmelCase :    Union[str, Any]				=			model(np.ones((1, 1)))
				self.assertIsNotNone(_SCREAMING_SNAKE_CASE)




"""simple docstring"""






def      _lowercase							(    __snake_case   ,__snake_case      )		->  int:
			return int((input_a, input_a).count(1      ) != 0      )


def      _lowercase							(    )		->  None:
			assert or_gate(0   ,0      ) == 0
			assert or_gate(0   ,1      ) == 1
			assert or_gate(1   ,0      ) == 1
			assert or_gate(1   ,1      ) == 1


if __name__ == "__main__":
	print(or_gate(0, 1))
	print(or_gate(1, 0))
	print(or_gate(0, 0))
	print(or_gate(1, 1))