





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







					'''simple docstring'''




					def __init__(						self	,			_UpperCAmelCase	,			_UpperCAmelCase=13	,			_UpperCAmelCase=7	,			_UpperCAmelCase=True	,			_UpperCAmelCase=True	,			_UpperCAmelCase=True	,			_UpperCAmelCase=True	,			_UpperCAmelCase=99	,			_UpperCAmelCase=32	,			_UpperCAmelCase=5	,			_UpperCAmelCase=4	,			_UpperCAmelCase=37	,			_UpperCAmelCase="gelu"	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=512	,			_UpperCAmelCase=16	,			_UpperCAmelCase=2	,			_UpperCAmelCase=0.0_2	,			_UpperCAmelCase=4	,			):
									__a :						List[str]			       =  parent
									__a :						int			       =  batch_size
									__a :						List[Any]			       =  seq_length
									__a :						Optional[int]			       =  is_training
									__a :						int			       =  use_attention_mask
									__a :						int			       =  use_token_type_ids
									__a :						int			       =  use_labels
									__a :						Optional[Any]			       =  vocab_size
									__a :						Optional[int]			       =  hidden_size
									__a :						Tuple			       =  num_hidden_layers
									__a :						Dict			       =  num_attention_heads
									__a :						List[str]			       =  intermediate_size
									__a :						int			       =  hidden_act
									__a :						str			       =  hidden_dropout_prob
									__a :						Optional[Any]			       =  attention_probs_dropout_prob
									__a :						Optional[int]			       =  max_position_embeddings
									__a :						int			       =  type_vocab_size
									__a :						int			       =  type_sequence_label_size
									__a :						Optional[int]			       =  initializer_range
									__a :						str			       =  num_choices







					def  _lowerCamelCase		(						self     ):
									__a :						List[Any]			       =  ids_tensor([self.batch_size, self.seq_length]	,			self.vocab_size     )

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

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

									__a :						Optional[Any]			       =  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     ):
									__a :						int			       =  self.prepare_config_and_inputs()
									__a :						List[Any]			       =  config_and_inputs
									__a :						int			       =  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
									return config, inputs_dict






@require_flax
class 				__lowercase			(			_UpperCamelCase   ,      unittest.TestCase							):







					'''simple docstring'''




					__lowerCAmelCase  =  (
					    (
					        FlaxAlbertModel,
					        FlaxAlbertForPreTraining,
					        FlaxAlbertForMaskedLM,
					        FlaxAlbertForMultipleChoice,
					        FlaxAlbertForQuestionAnswering,
					        FlaxAlbertForSequenceClassification,
					        FlaxAlbertForTokenClassification,
					        FlaxAlbertForQuestionAnswering,
					    )
					    if is_flax_available()
					    else ()
					)







					def  _lowerCamelCase		(						self     ):
									__a :						Tuple			       =  FlaxAlbertModelTester(self     )







					@slow
					def  _lowerCamelCase		(						self     ):
									for model_class_name in self.all_model_classes:
													__a :						Optional[int]			       =  model_class_name.from_pretrained('''albert-base-v2'''     )
													__a :						Tuple			       =  model(np.ones((1, 1)     )     )
													self.assertIsNotNone(_UpperCAmelCase     )






@require_flax
class 				__lowercase			(			unittest.TestCase							):







					'''simple docstring'''




					@slow
					def  _lowerCamelCase		(						self     ):
									__a :						Dict			       =  FlaxAlbertModel.from_pretrained('''albert-base-v2'''     )
									__a :						Optional[int]			       =  np.array([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]     )
									__a :						Optional[int]			       =  np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]     )
									__a :						str			       =  model(_UpperCAmelCase	,			attention_mask=_UpperCAmelCase     )[0]
									__a :						Tuple			       =  (1, 11, 768)
									self.assertEqual(output.shape	,			_UpperCAmelCase     )
									__a :						Dict			       =  np.array(
									    [[[-0.6_5_1_3, 1.5_0_3_5, -0.2_7_6_6], [-0.6_5_1_5, 1.5_0_4_6, -0.2_7_8_0], [-0.6_5_1_2, 1.5_0_4_9, -0.2_7_8_4]]]     )

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






"""simple docstring"""






def     __A      (			a_						:int = 2_00)		->		int:
				__a :						int			       =  [1, 2, 5, 10, 20, 50, 1_00, 2_00]
				__a :						List[Any]			       =  [0] * (pence + 1)
				__a :						Tuple			       =  1  # base case: 1 way to make 0 pence

				for coin in coins:
								for i in range(a_   ,       pence + 1   ,       1):
												number_of_ways[i] += number_of_ways[i - coin]
				return number_of_ways[pence]


if __name__ == "__main__":
		assert solution(200) == 73_682