





"""simple docstring"""






from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
    import tensorflow as tf

    from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
    from transformers.models.albert.modeling_tf_albert import (
        TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFAlbertForMaskedLM,
        TFAlbertForMultipleChoice,
        TFAlbertForPreTraining,
        TFAlbertForQuestionAnswering,
        TFAlbertForSequenceClassification,
        TFAlbertForTokenClassification,
        TFAlbertModel,
    )



class 						lowerCAmelCase       :






       def __init__( self     ,	a__     ,	a__=13     ,	a__=7     ,	a__=True     ,	a__=True     ,	a__=True     ,	a__=True     ,	a__=99     ,	a__=16     ,	a__=32     ,	a__=2     ,	a__=4     ,	a__=37     ,	a__="gelu"     ,	a__=0.1     ,	a__=0.1     ,	a__=5_12     ,	a__=16     ,	a__=2     ,	a__=0.02     ,	a__=3     ,	a__=4     ,	a__=None     ,	):
              _UpperCAmelCase			     =  parent
              _UpperCAmelCase			     =  13
              _UpperCAmelCase			     =  7
              _UpperCAmelCase			     =  True
              _UpperCAmelCase			     =  True
              _UpperCAmelCase			     =  True
              _UpperCAmelCase			     =  True
              _UpperCAmelCase			     =  99
              _UpperCAmelCase			     =  16
              _UpperCAmelCase			     =  32
              _UpperCAmelCase			     =  2
              _UpperCAmelCase			     =  4
              _UpperCAmelCase			     =  37
              _UpperCAmelCase			     =  'gelu'
              _UpperCAmelCase			     =  0.1
              _UpperCAmelCase			     =  0.1
              _UpperCAmelCase			     =  5_12
              _UpperCAmelCase			     =  16
              _UpperCAmelCase			     =  2
              _UpperCAmelCase			     =  0.02
              _UpperCAmelCase			     =  3
              _UpperCAmelCase			     =  4
              _UpperCAmelCase			     =  None






       def 				__A			( self  ):
              _UpperCAmelCase			     =  ids_tensor([self.batch_size, self.seq_length]     ,	self.vocab_size  )

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

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

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

              _UpperCAmelCase			     =  AlbertConfig(
                  vocab_size=self.vocab_size     ,	hidden_size=self.hidden_size     ,	embedding_size=self.embedding_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     ,	)

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






       def 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  TFAlbertModel(config=a__  )
              # inputs = {'input_ids': input_ids,
              #           'attention_mask': input_mask,
              #           'token_type_ids': token_type_ids}
              # sequence_output, pooled_output = model(**inputs)
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
              _UpperCAmelCase			     =  model(a__  )

              _UpperCAmelCase			     =  [input_ids, input_mask]
              _UpperCAmelCase			     =  model(a__  )

              _UpperCAmelCase			     =  model(a__  )

              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 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  self.num_labels
              _UpperCAmelCase			     =  TFAlbertForPreTraining(config=a__  )
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
              _UpperCAmelCase			     =  model(a__  )
              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, self.num_labels)  )






       def 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  TFAlbertForMaskedLM(config=a__  )
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
              _UpperCAmelCase			     =  model(a__  )
              self.parent.assertEqual(result.logits.shape     ,	(self.batch_size, self.seq_length, self.vocab_size)  )






       def 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  self.num_labels
              _UpperCAmelCase			     =  TFAlbertForSequenceClassification(config=a__  )
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
              _UpperCAmelCase			     =  model(a__  )
              self.parent.assertEqual(result.logits.shape     ,	(self.batch_size, self.num_labels)  )






       def 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  TFAlbertForQuestionAnswering(config=a__  )
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
              _UpperCAmelCase			     =  model(a__  )
              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 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  self.num_choices
              _UpperCAmelCase			     =  TFAlbertForMultipleChoice(config=a__  )
              _UpperCAmelCase			     =  tf.tile(tf.expand_dims(a__     ,	1  )     ,	(1, self.num_choices, 1)  )
              _UpperCAmelCase			     =  tf.tile(tf.expand_dims(a__     ,	1  )     ,	(1, self.num_choices, 1)  )
              _UpperCAmelCase			     =  tf.tile(tf.expand_dims(a__     ,	1  )     ,	(1, self.num_choices, 1)  )
              _UpperCAmelCase			     =  {
                  'input_ids': multiple_choice_inputs_ids,
                  'attention_mask': multiple_choice_input_mask,
                  'token_type_ids': multiple_choice_token_type_ids,
              }
              _UpperCAmelCase			     =  model(a__  )
              self.parent.assertListEqual(list(result['logits'].shape  )     ,	[self.batch_size, self.num_choices]  )






       def 				__A			( self     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__     ,	a__  ):
              _UpperCAmelCase			     =  self.num_labels
              _UpperCAmelCase			     =  TFAlbertForTokenClassification(config=a__  )
              _UpperCAmelCase			     =  {
                  'input_ids': input_ids,
                  'attention_mask': input_mask,
                  'token_type_ids': token_type_ids,
              }
              _UpperCAmelCase			     =  model(a__  )
              self.parent.assertListEqual(list(result['logits'].shape  )     ,	[self.batch_size, self.seq_length, self.num_labels]  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.prepare_config_and_inputs()
              (
                  (
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				(
                  _UpperCAmelCase
              )     ,				
              )			     =  config_and_inputs
              _UpperCAmelCase			     =  {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
              return config, inputs_dict



@require_tf
class 						lowerCAmelCase       (   snake_case      ,						snake_case      ,						unittest.TestCase				):
       lowerCAmelCase__    			=	(
           (
               TFAlbertModel,
               TFAlbertForPreTraining,
               TFAlbertForMaskedLM,
               TFAlbertForSequenceClassification,
               TFAlbertForQuestionAnswering,
               TFAlbertForTokenClassification,
               TFAlbertForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       lowerCAmelCase__    			=	(
           {
               """feature-extraction""": TFAlbertModel,
               """fill-mask""": TFAlbertForMaskedLM,
               """question-answering""": TFAlbertForQuestionAnswering,
               """text-classification""": TFAlbertForSequenceClassification,
               """token-classification""": TFAlbertForTokenClassification,
               """zero-shot""": TFAlbertForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )
       lowerCAmelCase__    			=	False
       lowerCAmelCase__    			=	False






       def 				__A			( self     ,	a__     ,	a__     ,	a__=False  ):
              _UpperCAmelCase			     =  super()._prepare_for_class(a__     ,	a__     ,	return_labels=a__  )

              if return_labels:
                     if model_class in get_values(a__  ):
                            _UpperCAmelCase			     =  tf.zeros(self.model_tester.batch_size     ,	dtype=tf.intaa  )

              return inputs_dict






       def 				__A			( self  ):
              _UpperCAmelCase			     =  TFAlbertModelTester(self  )
              _UpperCAmelCase			     =  ConfigTester(self     ,	config_class=a__     ,	hidden_size=37  )






       def 				__A			( self  ):
              self.config_tester.run_common_tests()






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_model(*a__  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_for_pretraining(*a__  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_for_masked_lm(*a__  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_for_multiple_choice(*a__  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_for_sequence_classification(*a__  )






       def 				__A			( self  ):
              _UpperCAmelCase			     =  self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_albert_for_question_answering(*a__  )






       @slow
       def 				__A			( self  ):
              for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                     _UpperCAmelCase			     =  TFAlbertModel.from_pretrained(a__  )
                     self.assertIsNotNone(a__  )



@require_tf
class 						lowerCAmelCase       (   unittest.TestCase				):






       @slow
       def 				__A			( self  ):
              _UpperCAmelCase			     =  TFAlbertForPreTraining.from_pretrained('albert-base-v2'  )
              _UpperCAmelCase			     =  tf.constant([[0, 1, 2, 3, 4, 5]]  )
              _UpperCAmelCase			     =  model(a__  )[0]

              _UpperCAmelCase			     =  [1, 6, 3_00_00]
              self.assertEqual(output.shape     ,	a__  )

              _UpperCAmelCase			     =  tf.constant(
                  [
                      [
                          [4.595_668, 0.74_462_754, -1.818_147],
                          [4.5_954_347, 0.7_454_184, -1.8_188_258],
                          [4.5_954_905, 0.7_448_235, -1.8_182_316],
                      ]
                  ]  )
              tf.debugging.assert_near(output[:, :3, :3]     ,	a__     ,	atol=1E-4  )













"""simple docstring"""






from collections import defaultdict

def    __lowerCamelCase     (							SCREAMING_SNAKE_CASE = 5				)		->							int:






       """simple docstring"""




       _UpperCAmelCase			     =  defaultdict(SCREAMING_SNAKE_CASE				)
       _UpperCAmelCase			     =  0

       while True:
              _UpperCAmelCase			     =  get_digits(SCREAMING_SNAKE_CASE				)
              freqs[digits].append(SCREAMING_SNAKE_CASE				)

              if len(freqs[digits]				) == max_base:
                     _UpperCAmelCase			     =  freqs[digits][0] ** 3
                     return base

              num += 1

def    __lowerCamelCase     (							SCREAMING_SNAKE_CASE				)		->							str:






       """simple docstring"""




       return "".join(sorted(str(num**3				)				)				)


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






