import copy
from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


if TYPE_CHECKING:
       from ... import PreTrainedTokenizerBase, TensorType

_SCREAMING_SNAKE_CASE					:  Union[str, Any]             =      logging.get_logger(__name__)






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  a									= "vision-encoder-decoder"
  a									= True






  def __init__(							self						:		Optional[Any]     ,       **__lowerCamelCase						:		Union[str, Any] )		->							int:
       super().__init__(**__lowerCamelCase )
       if "encoder" not in kwargs or "decoder" not in kwargs:
            raise ValueError(
                f'''A configuraton of type {self.model_type} cannot be instantiated because '''
                f'''not both `encoder` and `decoder` sub-configurations are passed, but only {kwargs}''' )

       SCREAMING_SNAKE_CASE__   =   kwargs.pop('''encoder''' )
       SCREAMING_SNAKE_CASE__   =   encoder_config.pop('''model_type''' )
       SCREAMING_SNAKE_CASE__   =   kwargs.pop('''decoder''' )
       SCREAMING_SNAKE_CASE__   =   decoder_config.pop('''model_type''' )

       SCREAMING_SNAKE_CASE__   =   AutoConfig.for_model(__lowerCamelCase     ,       **__lowerCamelCase )
       SCREAMING_SNAKE_CASE__   =   AutoConfig.for_model(__lowerCamelCase     ,       **__lowerCamelCase )
       SCREAMING_SNAKE_CASE__   =   True






  @classmethod
  def 				lowercase_		(							cls						:		Union[str, Any]     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		PretrainedConfig     ,       **__lowerCamelCase						:		Optional[int] )		->							PretrainedConfig:
       logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config''' )
       SCREAMING_SNAKE_CASE__   =   True
       SCREAMING_SNAKE_CASE__   =   True

       return cls(encoder=encoder_config.to_dict()     ,       decoder=decoder_config.to_dict()     ,       **__lowerCamelCase )







  def 				lowercase_		(							self						:		Tuple )		->							Union[str, Any]:
       SCREAMING_SNAKE_CASE__   =   copy.deepcopy(self.__dict__ )
       SCREAMING_SNAKE_CASE__   =   self.encoder.to_dict()
       SCREAMING_SNAKE_CASE__   =   self.decoder.to_dict()
       SCREAMING_SNAKE_CASE__   =   self.__class__.model_type
       return output






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  a									= version.parse("1.11"	)






  @property
  def 				lowercase_		(							self						:		Any )		->							Mapping[str, Mapping[int, str]]:
       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ] )






  @property
  def 				lowercase_		(							self						:		List[str] )		->							float:
       return 1e-4







  @property
  def 				lowercase_		(							self						:		List[str] )		->							Mapping[str, Mapping[int, str]]:
       return OrderedDict({'''last_hidden_state''': {0: '''batch''', 1: '''encoder_sequence'''}} )






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  @property
  def 				lowercase_		(							self						:		Optional[Any] )		->							Mapping[str, Mapping[int, str]]:
       SCREAMING_SNAKE_CASE__   =   OrderedDict()
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''encoder_sequence'''}

       return common_inputs







  def 				lowercase_		(							self						:		List[Any]     ,       __lowerCamelCase						:		"PreTrainedTokenizerBase"     ,       __lowerCamelCase						:		int = -1     ,       __lowerCamelCase						:		int = -1     ,       __lowerCamelCase						:		bool = False     ,       __lowerCamelCase						:		Optional["TensorType"] = None     ,       )		->							Mapping[str, Any]:
       import torch

       SCREAMING_SNAKE_CASE__   =   OrderedDict()

       SCREAMING_SNAKE_CASE__   =   super().generate_dummy_inputs(
           __lowerCamelCase     ,       batch_size=__lowerCamelCase     ,       seq_length=__lowerCamelCase     ,       is_pair=__lowerCamelCase     ,       framework=__lowerCamelCase )

       SCREAMING_SNAKE_CASE__,SCREAMING_SNAKE_CASE__   =   dummy_input['''input_ids'''].shape
       SCREAMING_SNAKE_CASE__   =   (batch, encoder_sequence, self._config.encoder_hidden_size)
       SCREAMING_SNAKE_CASE__   =   dummy_input.pop('''input_ids''' )
       SCREAMING_SNAKE_CASE__   =   dummy_input.pop('''attention_mask''' )
       SCREAMING_SNAKE_CASE__   =   torch.zeros(__lowerCamelCase )

       return common_inputs






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  @property
  def 				lowercase_		(							self						:		Any )		->							None:
       pass






  def 				lowercase_		(							self						:		Optional[Any]     ,       __lowerCamelCase						:		PretrainedConfig )		->							OnnxConfig:
       return VisionEncoderDecoderEncoderOnnxConfig(__lowerCamelCase )







  def 				lowercase_		(							self						:		Union[str, Any]     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		str = "default" )		->							OnnxConfig:
       SCREAMING_SNAKE_CASE__   =   encoder_config.hidden_size
       return VisionEncoderDecoderDecoderOnnxConfig(__lowerCamelCase     ,       __lowerCamelCase )





from functools import reduce

_SCREAMING_SNAKE_CASE					:  Any             =      (
    '''73167176531330624919225119674426574742355349194934'''
    '''96983520312774506326239578318016984801869478851843'''
    '''85861560789112949495459501737958331952853208805511'''
    '''12540698747158523863050715693290963295227443043557'''
    '''66896648950445244523161731856403098711121722383113'''
    '''62229893423380308135336276614282806444486645238749'''
    '''30358907296290491560440772390713810515859307960866'''
    '''70172427121883998797908792274921901699720888093776'''
    '''65727333001053367881220235421809751254540594752243'''
    '''52584907711670556013604839586446706324415722155397'''
    '''53697817977846174064955149290862569321978468622482'''
    '''83972241375657056057490261407972968652414535100474'''
    '''82166370484403199890008895243450658541227588666881'''
    '''16427171479924442928230863465674813919123162824586'''
    '''17866458359124566529476545682848912883142607690042'''
    '''24219022671055626321111109370544217506941658960408'''
    '''07198403850962455444362981230987879927244284909188'''
    '''84580156166097919133875499200524063689912560717606'''
    '''05886116467109405077541002256983155200055935729725'''
    '''71636269561882670428252483600823257530420752963450'''
)
def     UpperCAmelCase_       (						_A = N    ):





     '''simple docstring'''




     return max(
         # mypy cannot properly interpret reduce
         int(reduce(lambda _A				,		_A    : str(int(_A    ) * int(_A    )    )				,		n[i : i + 13]    )    )
         for i in range(len(_A    ) - 12    )    )


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


