




import unittest

import numpy as np

from transformers import DistilBertConfig, 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.distilbert.modeling_flax_distilbert import (
					    FlaxDistilBertForMaskedLM,
					    FlaxDistilBertForMultipleChoice,
					    FlaxDistilBertForQuestionAnswering,
					    FlaxDistilBertForSequenceClassification,
					    FlaxDistilBertForTokenClassification,
					    FlaxDistilBertModel,
					)
class     a__					(      unittest.TestCase   ):






						def __init__(     self	,    _A	,    _A=1_3	,    _A=7	,    _A=True	,    _A=True	,    _A=True	,    _A=True	,    _A=9_9	,    _A=3_2	,    _A=5	,    _A=4	,    _A=3_7	,    _A="gelu"	,    _A=0.1	,    _A=0.1	,    _A=5_1_2	,    _A=1_6	,    _A=2	,    _A=0.02	,    _A=4	,    ):




											"""simple docstring"""



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






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



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

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

											__lowerCAmelCase            = DistilBertConfig(
											    vocab_size=self.vocab_size	,    dim=self.hidden_size	,    n_layers=self.num_hidden_layers	,    n_heads=self.num_attention_heads	,    hidden_dim=self.intermediate_size	,    hidden_act=self.hidden_act	,    dropout=self.hidden_dropout_prob	,    attention_dropout=self.attention_probs_dropout_prob	,    max_position_embeddings=self.max_position_embeddings	,    initializer_range=self.initializer_range	,    tie_weights_=_A	,    )

											return config, input_ids, attention_mask






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.prepare_config_and_inputs()
											__lowerCAmelCase     ,							__lowerCAmelCase     ,							__lowerCAmelCase            = config_and_inputs
											__lowerCAmelCase            = {"input_ids": input_ids, "attention_mask": attention_mask}
											return config, inputs_dict






@require_flax
class     a__					(      snake_case__				,       unittest.TestCase   ):
						_a							:					List[str]      =					(
						    (
						        FlaxDistilBertModel,
						        FlaxDistilBertForMaskedLM,
						        FlaxDistilBertForMultipleChoice,
						        FlaxDistilBertForQuestionAnswering,
						        FlaxDistilBertForSequenceClassification,
						        FlaxDistilBertForTokenClassification,
						        FlaxDistilBertForQuestionAnswering,
						    )
						    if is_flax_available()
						    else ()
						)






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = FlaxDistilBertModelTester(self    )






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											for model_class_name in self.all_model_classes:
																__lowerCAmelCase            = model_class_name.from_pretrained("distilbert-base-uncased"    )
																__lowerCAmelCase            = model(np.ones((1, 1)    )    )
																self.assertIsNotNone(_A    )






@require_flax
class     a__					(      unittest.TestCase   ):






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = FlaxDistilBertModel.from_pretrained("distilbert-base-uncased"    )
											__lowerCAmelCase            = np.array([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]    )
											__lowerCAmelCase            = np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
											__lowerCAmelCase            = model(_A	,    attention_mask=_A    )[0]
											__lowerCAmelCase            = (1, 1_1, 7_6_8)
											self.assertEqual(output.shape	,    _A    )
											__lowerCAmelCase            = np.array([[[-0.16_39, 0.32_99, 0.16_48], [-0.17_46, 0.32_89, 0.17_10], [-0.18_84, 0.33_57, 0.18_10]]]    )

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










def 			_a   (		SCREAMING_SNAKE_CASE_							:       int   ,   SCREAMING_SNAKE_CASE_							:       int  ):
					if b == 0:
										return 1
					if (b % 2) == 0:
										return actual_power(SCREAMING_SNAKE_CASE_   ,   int(b / 2  )  ) * actual_power(SCREAMING_SNAKE_CASE_   ,   int(b / 2  )  )
					else:
										return a * actual_power(SCREAMING_SNAKE_CASE_   ,   int(b / 2  )  ) * actual_power(SCREAMING_SNAKE_CASE_   ,   int(b / 2  )  )







def 			_a   (		SCREAMING_SNAKE_CASE_							:       int   ,   SCREAMING_SNAKE_CASE_							:       int  ):
					if b < 0:
										return 1 / actual_power(SCREAMING_SNAKE_CASE_   ,   SCREAMING_SNAKE_CASE_  )
					return actual_power(SCREAMING_SNAKE_CASE_   ,   SCREAMING_SNAKE_CASE_  )


if __name__ == "__main__":
					print(power(-2, -3))




