




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






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

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






   def 	_lowerCAmelCase   (		self       :		List[Any]   )			->						str:

         """simple docstring"""
         lowerCAmelCase__      :			Tuple   =	ids_tensor([self.batch_size, self.seq_length]   ,     self.vocab_size   )

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

         lowerCAmelCase__      :			str   =	None
         if self.use_token_type_ids:
               lowerCAmelCase__      :			List[Any]   =	ids_tensor([self.batch_size, self.seq_length]   ,     self.type_vocab_size   )

         lowerCAmelCase__      :			Dict   =	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=UpperCamelCase   ,     initializer_range=self.initializer_range   ,     )

         return config, input_ids, token_type_ids, attention_mask






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

         """simple docstring"""
         lowerCAmelCase__      :			Optional[int]   =	self.prepare_config_and_inputs()
         lowerCAmelCase__ ,   lowerCAmelCase__ ,   lowerCAmelCase__ ,   lowerCAmelCase__      :			List[str]   =	config_and_inputs
         lowerCAmelCase__      :			str   =	{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": attention_mask}
         return config, inputs_dict






@require_flax
class _lowerCamelCase    (					a_       ,	unittest.TestCase						):
   _lowerCamelCase    :Optional[Any]     				=     (
       (
           FlaxAlbertModel,
           FlaxAlbertForPreTraining,
           FlaxAlbertForMaskedLM,
           FlaxAlbertForMultipleChoice,
           FlaxAlbertForQuestionAnswering,
           FlaxAlbertForSequenceClassification,
           FlaxAlbertForTokenClassification,
           FlaxAlbertForQuestionAnswering,
       )
       if is_flax_available()
       else ()
   )






   def 	_lowerCAmelCase   (		self       :		List[str]   )			->						Optional[Any]:

         """simple docstring"""
         lowerCAmelCase__      :			Any   =	FlaxAlbertModelTester(self   )






   @slow
   def 	_lowerCAmelCase   (		self       :		str   )			->						Tuple:

         """simple docstring"""
         for model_class_name in self.all_model_classes:
               lowerCAmelCase__      :			Union[str, Any]   =	model_class_name.from_pretrained("""albert-base-v2"""   )
               lowerCAmelCase__      :			List[Any]   =	model(np.ones((1, 1)   )   )
               self.assertIsNotNone(UpperCamelCase   )






@require_flax
class _lowerCamelCase    (					unittest.TestCase						):






   @slow
   def 	_lowerCAmelCase   (		self       :		List[Any]   )			->						str:

         """simple docstring"""
         lowerCAmelCase__      :			Optional[Any]   =	FlaxAlbertModel.from_pretrained("""albert-base-v2"""   )
         lowerCAmelCase__      :			int   =	np.array([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]   )
         lowerCAmelCase__      :			Optional[int]   =	np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
         lowerCAmelCase__      :			Optional[Any]   =	model(UpperCamelCase   ,     attention_mask=UpperCamelCase   )[0]
         lowerCAmelCase__      :			List[Any]   =	(1, 11, 7_68)
         self.assertEqual(output.shape   ,     UpperCamelCase   )
         lowerCAmelCase__      :			Optional[Any]   =	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]   ,     UpperCamelCase   ,     atol=1E-4   )   )











"""simple docstring"""


def 	lowercase_				(			__UpperCAmelCase    ,		__UpperCAmelCase				)						->    str:
      return "\n".join(
          f"""{number} * {i} = {number * i}""" for i in range(1    ,		number_of_terms + 1				)				)


if __name__ == "__main__":
  print(multiplication_table(number=5, number_of_terms=1_0))





