

from __future__ import annotations

import copy
import tempfile
import unittest

from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available
from transformers.testing_utils import (
    DUMMY_UNKNOWN_IDENTIFIER,
    SMALL_MODEL_IDENTIFIER,
    RequestCounter,
    require_tensorflow_probability,
    require_tf,
    slow,
)

from ..bert.test_modeling_bert import BertModelTester


if is_tf_available():
  from transformers import (
      TFAutoModel,
      TFAutoModelForCausalLM,
      TFAutoModelForMaskedLM,
      TFAutoModelForPreTraining,
      TFAutoModelForQuestionAnswering,
      TFAutoModelForSeqaSeqLM,
      TFAutoModelForSequenceClassification,
      TFAutoModelForTableQuestionAnswering,
      TFAutoModelForTokenClassification,
      TFAutoModelWithLMHead,
      TFBertForMaskedLM,
      TFBertForPreTraining,
      TFBertForQuestionAnswering,
      TFBertForSequenceClassification,
      TFBertModel,
      TFFunnelBaseModel,
      TFFunnelModel,
      TFGPTaLMHeadModel,
      TFRobertaForMaskedLM,
      TFTaForConditionalGeneration,
      TFTapasForQuestionAnswering,
  )
  from transformers.models.auto.modeling_tf_auto import (
      TF_MODEL_FOR_CAUSAL_LM_MAPPING,
      TF_MODEL_FOR_MASKED_LM_MAPPING,
      TF_MODEL_FOR_PRETRAINING_MAPPING,
      TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
      TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
      TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
      TF_MODEL_MAPPING,
  )
  from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
  from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
  from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST
  from transformers.models.tapas.modeling_tf_tapas import TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST





class 					__lowerCAmelCase	(   SCREAMING_SNAKE_CASE				):
  _a		     =    """new-model"""


if is_tf_available():





  class 					__lowerCAmelCase	(   SCREAMING_SNAKE_CASE				):
    _a		     =    NewModelConfig





@require_tf
class 					__lowerCAmelCase	(   unittest.TestCase				):




  @slow
  def     A__	(							self   )    ->					Optional[Any]:
        '''simple docstring'''






        _lowercase      			='bert-base-cased'
        _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
        self.assertIsNotNone(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

        _lowercase      			=TFAutoModel.from_pretrained(lowerCAmelCase   )
        self.assertIsNotNone(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					List[Any]:
        '''simple docstring'''






        _lowercase      			='bert-base-cased'
        _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
        self.assertIsNotNone(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

        _lowercase      			=TFAutoModelForPreTraining.from_pretrained(lowerCAmelCase   )
        self.assertIsNotNone(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					List[Any]:
        '''simple docstring'''






        for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForCausalLM.from_pretrained(lowerCAmelCase   )
              _lowercase			,			_lowercase      			=TFAutoModelForCausalLM.from_pretrained(lowerCAmelCase				,  output_loading_info=lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					Any:
        '''simple docstring'''






        for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelWithLMHead.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					str:
        '''simple docstring'''






        for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForMaskedLM.from_pretrained(lowerCAmelCase   )
              _lowercase			,			_lowercase      			=TFAutoModelForMaskedLM.from_pretrained(lowerCAmelCase				,  output_loading_info=lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					Optional[Any]:
        '''simple docstring'''






        for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase   )
              _lowercase			,			_lowercase      			=TFAutoModelForSeqaSeqLM.from_pretrained(lowerCAmelCase				,  output_loading_info=lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					List[Any]:
        '''simple docstring'''






        for model_name in ["bert-base-uncased"]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForSequenceClassification.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  def     A__	(							self   )    ->					int:
        '''simple docstring'''






        for model_name in ["bert-base-uncased"]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForQuestionAnswering.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  @slow
  @require_tensorflow_probability
  def     A__	(							self   )    ->					Any:
        '''simple docstring'''






        for model_name in TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST[5:6]:
              _lowercase      			=AutoConfig.from_pretrained(lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

              _lowercase      			=TFAutoModelForTableQuestionAnswering.from_pretrained(lowerCAmelCase   )
              _lowercase			,			_lowercase      			=TFAutoModelForTableQuestionAnswering.from_pretrained(
                  lowerCAmelCase				,  output_loading_info=lowerCAmelCase   )
              self.assertIsNotNone(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  def     A__	(							self   )    ->					Optional[int]:
        '''simple docstring'''






        _lowercase      			=TFAutoModelWithLMHead.from_pretrained(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )
        self.assertEqual(model.num_parameters()				,  14_410   )
        self.assertEqual(model.num_parameters(only_trainable=lowerCAmelCase   )				,  14_410   )




  def     A__	(							self   )    ->					Tuple:
        '''simple docstring'''






        _lowercase      			=TFAutoModelWithLMHead.from_pretrained(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )
        self.assertEqual(model.num_parameters()				,  14_410   )
        self.assertEqual(model.num_parameters(only_trainable=lowerCAmelCase   )				,  14_410   )




  def     A__	(							self   )    ->					str:
        '''simple docstring'''






        _lowercase      			=TFAutoModel.from_pretrained('sgugger/funnel-random-tiny'   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

        _lowercase      			=copy.deepcopy(model.config   )
        _lowercase      			=['FunnelBaseModel']
        _lowercase      			=TFAutoModel.from_config(lowerCAmelCase   )
        self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

        with tempfile.TemporaryDirectory() as tmp_dir:
              model.save_pretrained(lowerCAmelCase   )
              _lowercase      			=TFAutoModel.from_pretrained(lowerCAmelCase   )
              self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )




  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        try:
              AutoConfig.register('new-model'				,  lowerCAmelCase   )

              _lowercase      			=[
                  TFAutoModel,
                  TFAutoModelForCausalLM,
                  TFAutoModelForMaskedLM,
                  TFAutoModelForPreTraining,
                  TFAutoModelForQuestionAnswering,
                  TFAutoModelForSequenceClassification,
                  TFAutoModelForTokenClassification,
              ]

              for auto_class in auto_classes:
                    with self.subTest(auto_class.__name__   ):
                          # Wrong config class will raise an error
                          with self.assertRaises(lowerCAmelCase   ):
                                auto_class.register(lowerCAmelCase				,  lowerCAmelCase   )
                          auto_class.register(lowerCAmelCase				,  lowerCAmelCase   )
                          # Trying to register something existing in the Transformers library will raise an error
                          with self.assertRaises(lowerCAmelCase   ):
                                auto_class.register(lowerCAmelCase				,  lowerCAmelCase   )

                          # Now that the config is registered, it can be used as any other config with the auto-API
                          _lowercase      			=BertModelTester(self   ).get_config()
                          _lowercase      			=NewModelConfig(**tiny_config.to_dict()   )
                          _lowercase      			=auto_class.from_config(lowerCAmelCase   )
                          self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

                          with tempfile.TemporaryDirectory() as tmp_dir:
                                model.save_pretrained(lowerCAmelCase   )
                                _lowercase      			=auto_class.from_pretrained(lowerCAmelCase   )
                                self.assertIsInstance(lowerCAmelCase				,  lowerCAmelCase   )

        finally:
              if "new-model" in CONFIG_MAPPING._extra_content:
                    del CONFIG_MAPPING._extra_content["new-model"]
              for mapping in (
                  TF_MODEL_MAPPING,
                  TF_MODEL_FOR_PRETRAINING_MAPPING,
                  TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
                  TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
                  TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
                  TF_MODEL_FOR_CAUSAL_LM_MAPPING,
                  TF_MODEL_FOR_MASKED_LM_MAPPING,
              ):
                    if NewModelConfig in mapping._extra_content:
                          del mapping._extra_content[NewModelConfig]




  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        with self.assertRaisesRegex(
            lowerCAmelCase				,  'bert-base is not a local folder and is not a valid model identifier'   ):
              _lowercase      			=TFAutoModel.from_pretrained('bert-base'   )




  def     A__	(							self   )    ->					str:
        '''simple docstring'''






        with self.assertRaisesRegex(
            lowerCAmelCase				,  R'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'   ):
              _lowercase      			=TFAutoModel.from_pretrained(lowerCAmelCase				,  revision='aaaaaa'   )




  def     A__	(							self   )    ->					Dict:
        '''simple docstring'''






        with self.assertRaisesRegex(
            lowerCAmelCase				,  'hf-internal-testing/config-no-model does not appear to have a file named pytorch_model.bin'				,  ):
              _lowercase      			=TFAutoModel.from_pretrained('hf-internal-testing/config-no-model'   )




  def     A__	(							self   )    ->					int:
        '''simple docstring'''






        with self.assertRaisesRegex(lowerCAmelCase				,  'Use `from_pt=True` to load this model'   ):
              _lowercase      			=TFAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'   )




  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        _lowercase      			=TFAutoModel.from_pretrained('hf-internal-testing/tiny-random-bert'   )
        with RequestCounter() as counter:
              _lowercase      			=TFAutoModel.from_pretrained('hf-internal-testing/tiny-random-bert'   )
              self.assertEqual(counter.get_request_count				,  0   )
              self.assertEqual(counter.head_request_count				,  1   )
              self.assertEqual(counter.other_request_count				,  0   )

        # With a sharded checkpoint
        _lowercase      			=TFAutoModel.from_pretrained('ArthurZ/tiny-random-bert-sharded'   )
        with RequestCounter() as counter:
              _lowercase      			=TFAutoModel.from_pretrained('ArthurZ/tiny-random-bert-sharded'   )
              self.assertEqual(counter.get_request_count				,  0   )
              self.assertEqual(counter.head_request_count				,  1   )
              self.assertEqual(counter.other_request_count				,  0   )





import sys

lowercase_   							=  (
    '73167176531330624919225119674426574742355349194934'
    '96983520312774506326239578318016984801869478851843'
    '85861560789112949495459501737958331952853208805511'
    '12540698747158523863050715693290963295227443043557'
    '66896648950445244523161731856403098711121722383113'
    '62229893423380308135336276614282806444486645238749'
    '30358907296290491560440772390713810515859307960866'
    '70172427121883998797908792274921901699720888093776'
    '65727333001053367881220235421809751254540594752243'
    '52584907711670556013604839586446706324415722155397'
    '53697817977846174064955149290862569321978468622482'
    '83972241375657056057490261407972968652414535100474'
    '82166370484403199890008895243450658541227588666881'
    '16427171479924442928230863465674813919123162824586'
    '17866458359124566529476545682848912883142607690042'
    '24219022671055626321111109370544217506941658960408'
    '07198403850962455444362981230987879927244284909188'
    '84580156166097919133875499200524063689912560717606'
    '05886116467109405077541002256983155200055935729725'
    '71636269561882670428252483600823257530420752963450'
)
def 	a (     A__      :  str = N	)       -> int:





      """simple docstring"""



      _lowercase      			=-sys.maxsize - 1
      for i in range(len(A__	) - 12	):
            _lowercase      			=1
            for j in range(13	):
                  product *= int(n[i + j]	)
            if product > largest_product:
                  _lowercase      			=product
      return largest_product


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


