
"""simple docstring"""






import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    MODEL_FOR_PRETRAINING_MAPPING,
					    AlbertForMaskedLM,
					    AlbertForMultipleChoice,
					    AlbertForPreTraining,
					    AlbertForQuestionAnswering,
					    AlbertForSequenceClassification,
					    AlbertForTokenClassification,
					    AlbertModel,
					)
					from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST

class 					__a     :



							'''simple docstring'''







							def __init__(     self  ,    _lowerCamelCase  ,    _lowerCamelCase=13  ,    _lowerCamelCase=7  ,    _lowerCamelCase=True  ,    _lowerCamelCase=True  ,    _lowerCamelCase=True  ,    _lowerCamelCase=True  ,    _lowerCamelCase=99  ,    _lowerCamelCase=16  ,    _lowerCamelCase=36  ,    _lowerCamelCase=6  ,    _lowerCamelCase=6  ,    _lowerCamelCase=6  ,    _lowerCamelCase=37  ,    _lowerCamelCase="gelu"  ,    _lowerCamelCase=0.1  ,    _lowerCamelCase=0.1  ,    _lowerCamelCase=512  ,    _lowerCamelCase=16  ,    _lowerCamelCase=2  ,    _lowerCamelCase=0.02  ,    _lowerCamelCase=3  ,    _lowerCamelCase=4  ,    _lowerCamelCase=None  ,    )			->							Union[str, Any]:




										'''simple docstring'''
										__lowercase       =       parent
										__lowercase       =       batch_size
										__lowercase       =       seq_length
										__lowercase       =       is_training
										__lowercase       =       use_input_mask
										__lowercase       =       use_token_type_ids
										__lowercase       =       use_labels
										__lowercase       =       vocab_size
										__lowercase       =       embedding_size
										__lowercase       =       hidden_size
										__lowercase       =       num_hidden_layers
										__lowercase       =       num_hidden_groups
										__lowercase       =       num_attention_heads
										__lowercase       =       intermediate_size
										__lowercase       =       hidden_act
										__lowercase       =       hidden_dropout_prob
										__lowercase       =       attention_probs_dropout_prob
										__lowercase       =       max_position_embeddings
										__lowercase       =       type_vocab_size
										__lowercase       =       type_sequence_label_size
										__lowercase       =       initializer_range
										__lowercase       =       num_labels
										__lowercase       =       num_choices
										__lowercase       =       scope
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Dict:




										'''simple docstring'''
										__lowercase       =       ids_tensor([self.batch_size, self.seq_length]  ,    self.vocab_size       )

										__lowercase       =       None
										if self.use_input_mask:
													__lowercase       =       random_attention_mask([self.batch_size, self.seq_length]       )

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

										__lowercase       =       None
										__lowercase       =       None
										__lowercase       =       None
										if self.use_labels:
													__lowercase       =       ids_tensor([self.batch_size]  ,    self.type_sequence_label_size       )
													__lowercase       =       ids_tensor([self.batch_size, self.seq_length]  ,    self.num_labels       )
													__lowercase       =       ids_tensor([self.batch_size]  ,    self.num_choices       )

										__lowercase       =       self.get_config()

										return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Optional[Any]:




										'''simple docstring'''
										return 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  ,    initializer_range=self.initializer_range  ,    num_hidden_groups=self.num_hidden_groups  ,    )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Optional[Any]:




										'''simple docstring'''
										__lowercase       =       AlbertModel(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(_lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase       )
										__lowercase       =       model(_lowerCamelCase  ,    token_type_ids=_lowerCamelCase       )
										__lowercase       =       model(_lowerCamelCase       )
										self.parent.assertEqual(result.last_hidden_state.shape  ,    (self.batch_size, self.seq_length, self.hidden_size)       )
										self.parent.assertEqual(result.pooler_output.shape  ,    (self.batch_size, self.hidden_size)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							List[str]:




										'''simple docstring'''
										__lowercase       =       AlbertForPreTraining(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(
										    _lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    labels=_lowerCamelCase  ,    sentence_order_label=_lowerCamelCase  ,    )
										self.parent.assertEqual(result.prediction_logits.shape  ,    (self.batch_size, self.seq_length, self.vocab_size)       )
										self.parent.assertEqual(result.sop_logits.shape  ,    (self.batch_size, config.num_labels)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Dict:




										'''simple docstring'''
										__lowercase       =       AlbertForMaskedLM(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(_lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    labels=_lowerCamelCase       )
										self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.seq_length, self.vocab_size)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Union[str, Any]:




										'''simple docstring'''
										__lowercase       =       AlbertForQuestionAnswering(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(
										    _lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    start_positions=_lowerCamelCase  ,    end_positions=_lowerCamelCase  ,    )
										self.parent.assertEqual(result.start_logits.shape  ,    (self.batch_size, self.seq_length)       )
										self.parent.assertEqual(result.end_logits.shape  ,    (self.batch_size, self.seq_length)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Any:




										'''simple docstring'''
										__lowercase       =       self.num_labels
										__lowercase       =       AlbertForSequenceClassification(_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(_lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    labels=_lowerCamelCase       )
										self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.num_labels)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Union[str, Any]:




										'''simple docstring'''
										__lowercase       =       self.num_labels
										__lowercase       =       AlbertForTokenClassification(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       model(_lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    labels=_lowerCamelCase       )
										self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.seq_length, self.num_labels)       )
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase       )			->							Dict:




										'''simple docstring'''
										__lowercase       =       self.num_choices
										__lowercase       =       AlbertForMultipleChoice(config=_lowerCamelCase       )
										model.to(_lowerCamelCase       )
										model.eval()
										__lowercase       =       input_ids.unsqueeze(1       ).expand(-1  ,    self.num_choices  ,    -1       ).contiguous()
										__lowercase       =       token_type_ids.unsqueeze(1       ).expand(-1  ,    self.num_choices  ,    -1       ).contiguous()
										__lowercase       =       input_mask.unsqueeze(1       ).expand(-1  ,    self.num_choices  ,    -1       ).contiguous()
										__lowercase       =       model(
										    _lowerCamelCase  ,    attention_mask=_lowerCamelCase  ,    token_type_ids=_lowerCamelCase  ,    labels=_lowerCamelCase  ,    )
										self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.num_choices)       )





							def   SCREAMING_SNAKE_CASE						(     self       )			->							List[Any]:




										'''simple docstring'''
										__lowercase       =       self.prepare_config_and_inputs()
										(
										    (
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					(
										    __lowercase
										)   ,					
										)       =       config_and_inputs
										__lowercase       =       {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
										return config, inputs_dict





@require_torch
class 					__a     ( __a					,   __a					,   unittest.TestCase       ):



							'''simple docstring'''







							_lowerCamelCase					:			Optional[int]          =   (
							    (
							        AlbertModel,
							        AlbertForPreTraining,
							        AlbertForMaskedLM,
							        AlbertForMultipleChoice,
							        AlbertForSequenceClassification,
							        AlbertForTokenClassification,
							        AlbertForQuestionAnswering,
							    )
							    if is_torch_available()
							    else ()
							)
							_lowerCamelCase					:			Optional[int]          =   (
							    {
							        """feature-extraction""": AlbertModel,
							        """fill-mask""": AlbertForMaskedLM,
							        """question-answering""": AlbertForQuestionAnswering,
							        """text-classification""": AlbertForSequenceClassification,
							        """token-classification""": AlbertForTokenClassification,
							        """zero-shot""": AlbertForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							_lowerCamelCase					:			Optional[Any]          =   True
							def   SCREAMING_SNAKE_CASE						(     self  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase=False       )			->							Optional[int]:




										'''simple docstring'''
										__lowercase       =       super()._prepare_for_class(_lowerCamelCase  ,    _lowerCamelCase  ,    return_labels=_lowerCamelCase       )

										if return_labels:
													if model_class in get_values(_lowerCamelCase       ):
																__lowercase       =       torch.zeros(
																    (self.model_tester.batch_size, self.model_tester.seq_length)  ,    dtype=torch.long  ,    device=_lowerCamelCase       )
																__lowercase       =       torch.zeros(
																    self.model_tester.batch_size  ,    dtype=torch.long  ,    device=_lowerCamelCase       )
										return inputs_dict
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Optional[Any]:




										'''simple docstring'''
										__lowercase       =       AlbertModelTester(self       )
										__lowercase       =       ConfigTester(self  ,    config_class=_lowerCamelCase  ,    hidden_size=37       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Union[str, Any]:




										'''simple docstring'''
										self.config_tester.run_common_tests()
							def   SCREAMING_SNAKE_CASE						(     self       )			->							List[str]:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Optional[Any]:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_pretraining(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Dict:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Tuple:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_multiple_choice(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Union[str, Any]:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							Optional[Any]:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*_lowerCamelCase       )
							def   SCREAMING_SNAKE_CASE						(     self       )			->							List[str]:




										'''simple docstring'''
										__lowercase       =       self.model_tester.prepare_config_and_inputs()
										for type in ["absolute", "relative_key", "relative_key_query"]:
													__lowercase       =       type
													self.model_tester.create_and_check_model(*_lowerCamelCase       )





							@slow
							def   SCREAMING_SNAKE_CASE						(     self       )			->							str:




										'''simple docstring'''
										for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													__lowercase       =       AlbertModel.from_pretrained(_lowerCamelCase       )
													self.assertIsNotNone(_lowerCamelCase       )





@require_torch
class 					__a     ( unittest.TestCase       ):



							'''simple docstring'''







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




										'''simple docstring'''
										__lowercase       =       AlbertModel.from_pretrained("albert-base-v2"       )
										__lowercase       =       torch.tensor([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]       )
										__lowercase       =       torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]       )
										with torch.no_grad():
													__lowercase       =       model(_lowerCamelCase  ,    attention_mask=_lowerCamelCase       )[0]
										__lowercase       =       torch.Size((1, 11, 768)       )
										self.assertEqual(output.shape  ,    _lowerCamelCase       )
										__lowercase       =       torch.tensor(
										    [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]       )

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







"""simple docstring"""






def      lowerCAmelCase__			(		__magic_name__ = 1_0      )						->str:
			if not isinstance(__magic_name__			,   __magic_name__      ) or n < 0:
						raise ValueError("Invalid input"      )
			__lowercase       =       1_0**n
			__lowercase       =       2_8_4_3_3 * (pow(2			,   7_8_3_0_4_5_7			,   __magic_name__      )) + 1
			return str(number % modulus      )


if __name__ == "__main__":
					from doctest import testmod

					testmod()
					print(F"{solution(10) = }")





