



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       _SCREAMING_SNAKE_CASE	:





     def __init__(       self :							Optional[int]     ,  UpperCamelCase :							List[Any]     ,  UpperCamelCase :							Any=1_3     ,  UpperCamelCase :							Union[str, Any]=7     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							Any=True     ,  UpperCamelCase :							List[str]=True     ,  UpperCamelCase :							Dict=True     ,  UpperCamelCase :							Tuple=9_9     ,  UpperCamelCase :							Dict=1_6     ,  UpperCamelCase :							Any=3_6     ,  UpperCamelCase :							int=6     ,  UpperCamelCase :							Optional[int]=6     ,  UpperCamelCase :							str=6     ,  UpperCamelCase :							Dict=3_7     ,  UpperCamelCase :							Tuple="gelu"     ,  UpperCamelCase :							Tuple=0.1     ,  UpperCamelCase :							int=0.1     ,  UpperCamelCase :							Tuple=5_1_2     ,  UpperCamelCase :							Dict=1_6     ,  UpperCamelCase :							Any=2     ,  UpperCamelCase :							Union[str, Any]=0.0_2     ,  UpperCamelCase :							Tuple=3     ,  UpperCamelCase :							Any=4     ,  UpperCamelCase :							List[str]=None     ,  )->int:
      __SCREAMING_SNAKE_CASE       :    str       =	parent
      __SCREAMING_SNAKE_CASE       :    Tuple       =	batch_size
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	seq_length
      __SCREAMING_SNAKE_CASE       :    str       =	is_training
      __SCREAMING_SNAKE_CASE       :    int       =	use_input_mask
      __SCREAMING_SNAKE_CASE       :    Tuple       =	use_token_type_ids
      __SCREAMING_SNAKE_CASE       :    Tuple       =	use_labels
      __SCREAMING_SNAKE_CASE       :    Tuple       =	vocab_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	embedding_size
      __SCREAMING_SNAKE_CASE       :    Dict       =	hidden_size
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	num_hidden_layers
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	num_hidden_groups
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	num_attention_heads
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	intermediate_size
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	hidden_act
      __SCREAMING_SNAKE_CASE       :    str       =	hidden_dropout_prob
      __SCREAMING_SNAKE_CASE       :    List[str]       =	attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE       :    Tuple       =	max_position_embeddings
      __SCREAMING_SNAKE_CASE       :    Tuple       =	type_vocab_size
      __SCREAMING_SNAKE_CASE       :    Tuple       =	type_sequence_label_size
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	initializer_range
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	num_labels
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	num_choices
      __SCREAMING_SNAKE_CASE       :    str       =	scope





     def 	__snake_case    (       self :							int				)->Union[str, Any]:
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.vocab_size				)

      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	None
      if self.use_input_mask:
       __SCREAMING_SNAKE_CASE       :    Optional[int]       =	random_attention_mask([self.batch_size, self.seq_length]				)

      __SCREAMING_SNAKE_CASE       :    List[str]       =	None
      if self.use_token_type_ids:
       __SCREAMING_SNAKE_CASE       :    Optional[int]       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.type_vocab_size				)

      __SCREAMING_SNAKE_CASE       :    List[Any]       =	None
      __SCREAMING_SNAKE_CASE       :    List[str]       =	None
      __SCREAMING_SNAKE_CASE       :    List[str]       =	None
      if self.use_labels:
       __SCREAMING_SNAKE_CASE       :    List[str]       =	ids_tensor([self.batch_size]     ,  self.type_sequence_label_size				)
       __SCREAMING_SNAKE_CASE       :    Optional[int]       =	ids_tensor([self.batch_size, self.seq_length]     ,  self.num_labels				)
       __SCREAMING_SNAKE_CASE       :    Optional[int]       =	ids_tensor([self.batch_size]     ,  self.num_choices				)

      __SCREAMING_SNAKE_CASE       :    str       =	self.get_config()

      return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





     def 	__snake_case    (       self :							str				)->int:
      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 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							int				)->List[Any]:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	AlbertModel(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	model(UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	model(UpperCamelCase     ,  token_type_ids=UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	model(UpperCamelCase				)
      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 	__snake_case    (       self :							Any     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							int     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							Tuple				)->int:
      __SCREAMING_SNAKE_CASE       :    str       =	AlbertForPreTraining(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	model(
          UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase     ,  sentence_order_label=UpperCamelCase     ,  )
      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 	__snake_case    (       self :							Union[str, Any]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Dict     ,  UpperCamelCase :							int     ,  UpperCamelCase :							str     ,  UpperCamelCase :							int     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							Union[str, Any]				)->List[str]:
      __SCREAMING_SNAKE_CASE       :    Any       =	AlbertForMaskedLM(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	model(UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase				)
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.vocab_size)				)





     def 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							Dict     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Dict     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							List[str]				)->Tuple:
      __SCREAMING_SNAKE_CASE       :    str       =	AlbertForQuestionAnswering(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    int       =	model(
          UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  start_positions=UpperCamelCase     ,  end_positions=UpperCamelCase     ,  )
      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 	__snake_case    (       self :							Tuple     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							Dict     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							List[Any]     ,  UpperCamelCase :							List[Any]				)->Tuple:
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	self.num_labels
      __SCREAMING_SNAKE_CASE       :    Tuple       =	AlbertForSequenceClassification(UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    Any       =	model(UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase				)
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_labels)				)





     def 	__snake_case    (       self :							int     ,  UpperCamelCase :							List[Any]     ,  UpperCamelCase :							int     ,  UpperCamelCase :							Tuple     ,  UpperCamelCase :							Union[str, Any]     ,  UpperCamelCase :							Optional[Any]     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							str				)->Dict:
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	self.num_labels
      __SCREAMING_SNAKE_CASE       :    Any       =	AlbertForTokenClassification(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	model(UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase				)
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.num_labels)				)





     def 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							List[Any]     ,  UpperCamelCase :							List[Any]     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							List[str]     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Dict				)->Any:
      __SCREAMING_SNAKE_CASE       :    Any       =	self.num_choices
      __SCREAMING_SNAKE_CASE       :    Tuple       =	AlbertForMultipleChoice(config=UpperCamelCase				)
      model.to(UpperCamelCase				)
      model.eval()
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	input_ids.unsqueeze(1				).expand(-1     ,  self.num_choices     ,  -1				).contiguous()
      __SCREAMING_SNAKE_CASE       :    Tuple       =	token_type_ids.unsqueeze(1				).expand(-1     ,  self.num_choices     ,  -1				).contiguous()
      __SCREAMING_SNAKE_CASE       :    Dict       =	input_mask.unsqueeze(1				).expand(-1     ,  self.num_choices     ,  -1				).contiguous()
      __SCREAMING_SNAKE_CASE       :    int       =	model(
          UpperCamelCase     ,  attention_mask=UpperCamelCase     ,  token_type_ids=UpperCamelCase     ,  labels=UpperCamelCase     ,  )
      self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_choices)				)






     def 	__snake_case    (       self :							List[str]				)->Optional[Any]:
      __SCREAMING_SNAKE_CASE       :    Dict       =	self.prepare_config_and_inputs()
      (
          (
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		(
          __SCREAMING_SNAKE_CASE
      ),		
      )       :    Optional[Any]       =	config_and_inputs
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
      return config, inputs_dict






@require_torch
class       _SCREAMING_SNAKE_CASE	(UpperCamelCase			,    UpperCamelCase			,    unittest.TestCase ):
     lowerCAmelCase					=			(
         (
             AlbertModel,
             AlbertForPreTraining,
             AlbertForMaskedLM,
             AlbertForMultipleChoice,
             AlbertForSequenceClassification,
             AlbertForTokenClassification,
             AlbertForQuestionAnswering,
         )
         if is_torch_available()
         else ()
     )
     lowerCAmelCase					=			(
         {
             """feature-extraction""": AlbertModel,
             """fill-mask""": AlbertForMaskedLM,
             """question-answering""": AlbertForQuestionAnswering,
             """text-classification""": AlbertForSequenceClassification,
             """token-classification""": AlbertForTokenClassification,
             """zero-shot""": AlbertForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     lowerCAmelCase					=			True





     def 	__snake_case    (       self :							Dict     ,  UpperCamelCase :							Any     ,  UpperCamelCase :							Optional[int]     ,  UpperCamelCase :							str=False				)->Union[str, Any]:
      __SCREAMING_SNAKE_CASE       :    Optional[int]       =	super()._prepare_for_class(UpperCamelCase     ,  UpperCamelCase     ,  return_labels=UpperCamelCase				)

      if return_labels:
       if model_class in get_values(UpperCamelCase				):
        __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	torch.zeros(
            (self.model_tester.batch_size, self.model_tester.seq_length)     ,  dtype=torch.long     ,  device=UpperCamelCase				)
        __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	torch.zeros(
            self.model_tester.batch_size     ,  dtype=torch.long     ,  device=UpperCamelCase				)
      return inputs_dict





     def 	__snake_case    (       self :							List[Any]				)->Dict:
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	AlbertModelTester(self				)
      __SCREAMING_SNAKE_CASE       :    int       =	ConfigTester(self     ,  config_class=UpperCamelCase     ,  hidden_size=3_7				)





     def 	__snake_case    (       self :							str				)->int:
      self.config_tester.run_common_tests()





     def 	__snake_case    (       self :							List[str]				)->Optional[int]:
      __SCREAMING_SNAKE_CASE       :    Tuple       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*UpperCamelCase				)





     def 	__snake_case    (       self :							Tuple				)->List[str]:
      __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_pretraining(*UpperCamelCase				)





     def 	__snake_case    (       self :							str				)->List[str]:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase				)





     def 	__snake_case    (       self :							Optional[Any]				)->Any:
      __SCREAMING_SNAKE_CASE       :    List[str]       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*UpperCamelCase				)





     def 	__snake_case    (       self :							Any				)->List[Any]:
      __SCREAMING_SNAKE_CASE       :    int       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*UpperCamelCase				)





     def 	__snake_case    (       self :							Dict				)->Union[str, Any]:
      __SCREAMING_SNAKE_CASE       :    Any       =	self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase				)





     def 	__snake_case    (       self :							Tuple				)->Optional[int]:
      __SCREAMING_SNAKE_CASE       :    Dict       =	self.model_tester.prepare_config_and_inputs()
      for type in ["absolute", "relative_key", "relative_key_query"]:
       __SCREAMING_SNAKE_CASE       :    int       =	type
       self.model_tester.create_and_check_model(*UpperCamelCase				)






     @slow
     def 	__snake_case    (       self :							Optional[int]				)->int:
      for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       __SCREAMING_SNAKE_CASE       :    int       =	AlbertModel.from_pretrained(UpperCamelCase				)
       self.assertIsNotNone(UpperCamelCase				)






@require_torch
class       _SCREAMING_SNAKE_CASE	(unittest.TestCase ):





     @slow
     def 	__snake_case    (       self :							str				)->Optional[Any]:
      __SCREAMING_SNAKE_CASE       :    List[Any]       =	AlbertModel.from_pretrained("albert-base-v2"				)
      __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	torch.tensor([[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]]				)
      __SCREAMING_SNAKE_CASE       :    Any       =	torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]				)
      with torch.no_grad():
       __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	model(UpperCamelCase     ,  attention_mask=UpperCamelCase				)[0]
      __SCREAMING_SNAKE_CASE       :    Tuple       =	torch.Size((1, 1_1, 7_6_8)				)
      self.assertEqual(output.shape     ,  UpperCamelCase				)
      __SCREAMING_SNAKE_CASE       :    int       =	torch.tensor(
          [[[-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(torch.allclose(output[:, 1:4, 1:4]     ,  UpperCamelCase     ,  atol=1E-4				)				)











from math import sqrt






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int = 1000000     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int

 while num_cuboids <= limit:
  max_cuboid_size += 1
  for sum_shortest_sides in range(2		,	2 * max_cuboid_size + 1     ):
   if sqrt(sum_shortest_sides**2 + max_cuboid_size**2     ).is_integer():
    num_cuboids += (
        min(__lowerCamelCase		,	sum_shortest_sides // 2     )
        - max(1		,	sum_shortest_sides - max_cuboid_size     )
        + 1
    )

 return max_cuboid_size


if __name__ == "__main__":
      print(f'''{solution() = }''')






