

'''simple docstring'''







import unittest

from transformers import LiltConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          LiltForQuestionAnswering,
          LiltForSequenceClassification,
          LiltForTokenClassification,
          LiltModel,
      )
      from transformers.models.lilt.modeling_lilt import LILT_PRETRAINED_MODEL_ARCHIVE_LIST


class    A__ :



    def __init__(   self						,			UpperCamelCase__						,			UpperCamelCase__=13						,			UpperCamelCase__=7						,			UpperCamelCase__=True						,			UpperCamelCase__=True						,			UpperCamelCase__=True						,			UpperCamelCase__=True						,			UpperCamelCase__=99						,			UpperCamelCase__=24						,			UpperCamelCase__=2						,			UpperCamelCase__=6						,			UpperCamelCase__=37						,			UpperCamelCase__="gelu"						,			UpperCamelCase__=0.1						,			UpperCamelCase__=0.1						,			UpperCamelCase__=512						,			UpperCamelCase__=16						,			UpperCamelCase__=2						,			UpperCamelCase__=0.02						,			UpperCamelCase__=3						,			UpperCamelCase__=None						,			UpperCamelCase__=1000						,			)  -> int:





           '''simple docstring'''
           A_		   = parent
           A_		   = batch_size
           A_		   = seq_length
           A_		   = is_training
           A_		   = use_input_mask
           A_		   = use_token_type_ids
           A_		   = use_labels
           A_		   = vocab_size
           A_		   = hidden_size
           A_		   = num_hidden_layers
           A_		   = num_attention_heads
           A_		   = intermediate_size
           A_		   = hidden_act
           A_		   = hidden_dropout_prob
           A_		   = attention_probs_dropout_prob
           A_		   = max_position_embeddings
           A_		   = type_vocab_size
           A_		   = type_sequence_label_size
           A_		   = initializer_range
           A_		   = num_labels
           A_		   = scope
           A_		   = range_bbox



    def    snake_case_     (   self    )  -> Dict:





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

           A_		   = ids_tensor([self.batch_size, self.seq_length, 4]						,			self.range_bbox    )
           # Ensure that bbox is legal
           for i in range(bbox.shape[0]    ):
                  for j in range(bbox.shape[1]    ):
                         if bbox[i, j, 3] < bbox[i, j, 1]:
                                A_		   = bbox[i, j, 3]
                                A_		   = bbox[i, j, 1]
                                A_		   = t
                         if bbox[i, j, 2] < bbox[i, j, 0]:
                                A_		   = bbox[i, j, 2]
                                A_		   = bbox[i, j, 0]
                                A_		   = t

           A_		   = None
           if self.use_input_mask:
                  A_		   = ids_tensor([self.batch_size, self.seq_length]						,			vocab_size=2    )

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

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

           A_		   = self.get_config()

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



    def    snake_case_     (   self    )  -> Union[str, Any]:





           '''simple docstring'''
           return LiltConfig(
               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						,			)



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			)  -> Any:





           '''simple docstring'''
           A_		   = LiltModel(config=_SCREAMING_SNAKE_CASE    )
           model.to(_SCREAMING_SNAKE_CASE    )
           model.eval()
           A_		   = model(_SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE						,			attention_mask=_SCREAMING_SNAKE_CASE						,			token_type_ids=_SCREAMING_SNAKE_CASE    )
           A_		   = model(_SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE						,			token_type_ids=_SCREAMING_SNAKE_CASE    )
           A_		   = model(_SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE    )

           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						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			)  -> List[str]:





           '''simple docstring'''
           A_		   = self.num_labels
           A_		   = LiltForTokenClassification(config=_SCREAMING_SNAKE_CASE    )
           model.to(_SCREAMING_SNAKE_CASE    )
           model.eval()
           A_		   = model(
               _SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE						,			attention_mask=_SCREAMING_SNAKE_CASE						,			token_type_ids=_SCREAMING_SNAKE_CASE						,			labels=_SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.logits.shape						,			(self.batch_size, self.seq_length, self.num_labels)    )



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			)  -> List[Any]:





           '''simple docstring'''
           A_		   = LiltForQuestionAnswering(config=_SCREAMING_SNAKE_CASE    )
           model.to(_SCREAMING_SNAKE_CASE    )
           model.eval()
           A_		   = model(
               _SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE						,			attention_mask=_SCREAMING_SNAKE_CASE						,			token_type_ids=_SCREAMING_SNAKE_CASE						,			start_positions=_SCREAMING_SNAKE_CASE						,			end_positions=_SCREAMING_SNAKE_CASE						,			)
           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:





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


@require_torch
class    A__ ( SCREAMING_SNAKE_CASE__  ,  SCREAMING_SNAKE_CASE__  ,  SCREAMING_SNAKE_CASE__  ,  unittest.TestCase     ):
    lowercase		   =						(
        (
            LiltModel,
            LiltForSequenceClassification,
            LiltForTokenClassification,
            LiltForQuestionAnswering,
        )
        if is_torch_available()
        else ()
    )
    lowercase		   =						(
        {
            'feature-extraction': LiltModel,
            'question-answering': LiltForQuestionAnswering,
            'text-classification': LiltForSequenceClassification,
            'token-classification': LiltForTokenClassification,
            'zero-shot': LiltForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    lowercase		   =						False
    lowercase		   =						False



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__    )  -> Dict:





           '''simple docstring'''
           return True



    def    snake_case_     (   self    )  -> str:





           '''simple docstring'''
           A_		   = LiltModelTester(self    )
           A_		   = ConfigTester(self						,			config_class=_SCREAMING_SNAKE_CASE						,			hidden_size=37    )



    def    snake_case_     (   self    )  -> str:





           '''simple docstring'''
           self.config_tester.run_common_tests()



    def    snake_case_     (   self    )  -> int:





           '''simple docstring'''
           A_		   = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE    )



    def    snake_case_     (   self    )  -> Union[str, Any]:





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



    def    snake_case_     (   self    )  -> str:





           '''simple docstring'''
           A_		   = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_token_classification(*_SCREAMING_SNAKE_CASE    )



    def    snake_case_     (   self    )  -> List[str]:





           '''simple docstring'''
           A_		   = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*_SCREAMING_SNAKE_CASE    )







    @slow
    def    snake_case_     (   self    )  -> Optional[Any]:





           '''simple docstring'''
           for model_name in LILT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                  A_		   = LiltModel.from_pretrained(_SCREAMING_SNAKE_CASE    )
                  self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )


@require_torch
@slow
class    A__ ( unittest.TestCase     ):



    def    snake_case_     (   self    )  -> str:





           '''simple docstring'''
           A_		   = LiltModel.from_pretrained("""SCUT-DLVCLab/lilt-roberta-en-base"""    ).to(_SCREAMING_SNAKE_CASE    )

           A_		   = torch.tensor([[1, 2]]						,			device=_SCREAMING_SNAKE_CASE    )
           A_		   = torch.tensor([[[1, 2, 3, 4], [5, 6, 7, 8]]]						,			device=_SCREAMING_SNAKE_CASE    )

           # forward pass
           with torch.no_grad():
                  A_		   = model(input_ids=_SCREAMING_SNAKE_CASE						,			bbox=_SCREAMING_SNAKE_CASE    )

           A_		   = torch.Size([1, 2, 768]    )
           A_		   = torch.tensor(
               [[-0.0653, 0.0950, -0.0061], [-0.0545, 0.0926, -0.0324]]						,			device=_SCREAMING_SNAKE_CASE						,			)

           self.assertTrue(outputs.last_hidden_state.shape						,			_SCREAMING_SNAKE_CASE    )
           self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :, :3]						,			_SCREAMING_SNAKE_CASE						,			atol=1e-3    )    )



'''simple docstring'''







import sys

__lowerCamelCase						    =      (
    '''73167176531330624919225119674426574742355349194934'''
    '''96983520312774506326239578318016984801869478851843'''
    '''85861560789112949495459501737958331952853208805511'''
    '''12540698747158523863050715693290963295227443043557'''
    '''66896648950445244523161731856403098711121722383113'''
    '''62229893423380308135336276614282806444486645238749'''
    '''30358907296290491560440772390713810515859307960866'''
    '''70172427121883998797908792274921901699720888093776'''
    '''65727333001053367881220235421809751254540594752243'''
    '''52584907711670556013604839586446706324415722155397'''
    '''53697817977846174064955149290862569321978468622482'''
    '''83972241375657056057490261407972968652414535100474'''
    '''82166370484403199890008895243450658541227588666881'''
    '''16427171479924442928230863465674813919123162824586'''
    '''17866458359124566529476545682848912883142607690042'''
    '''24219022671055626321111109370544217506941658960408'''
    '''07198403850962455444362981230987879927244284909188'''
    '''84580156166097919133875499200524063689912560717606'''
    '''05886116467109405077541002256983155200055935729725'''
    '''71636269561882670428252483600823257530420752963450'''
)
def  UpperCAmelCase__      ( UpperCAmelCase__ = N			)     ->     int:
       A_		   = -sys.maxsize - 1
       for i in range(len(UpperCAmelCase__			) - 12			):
              A_		   = 1
              for j in range(13			):
                     product *= int(n[i + j]			)
              if product > largest_product:
                     A_		   = product
       return largest_product


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