





'''simple docstring'''







import sys

_lowercase       						=			(
    '73167176531330624919225119674426574742355349194934'
    '96983520312774506326239578318016984801869478851843'
    '85861560789112949495459501737958331952853208805511'
    '12540698747158523863050715693290963295227443043557'
    '66896648950445244523161731856403098711121722383113'
    '62229893423380308135336276614282806444486645238749'
    '30358907296290491560440772390713810515859307960866'
    '70172427121883998797908792274921901699720888093776'
    '65727333001053367881220235421809751254540594752243'
    '52584907711670556013604839586446706324415722155397'
    '53697817977846174064955149290862569321978468622482'
    '83972241375657056057490261407972968652414535100474'
    '82166370484403199890008895243450658541227588666881'
    '16427171479924442928230863465674813919123162824586'
    '17866458359124566529476545682848912883142607690042'
    '24219022671055626321111109370544217506941658960408'
    '07198403850962455444362981230987879927244284909188'
    '84580156166097919133875499200524063689912560717606'
    '05886116467109405077541002256983155200055935729725'
    '71636269561882670428252483600823257530420752963450'
)



def    __UpperCamelCase	(	a    : str     ) ->Dict:
 snake_case				=			1
 for digit in s:
  product *= int(__a     )
 return product



def    __UpperCamelCase	(	a    : str = N     ) ->Optional[int]:
 snake_case				=			-sys.maxsize - 1
 snake_case				=			n[:13]
 snake_case				=			13
 while cur_index < len(__a     ) - 13:
  if int(n[cur_index]     ) >= int(substr[0]     ):
   snake_case				=			substr[1:] + n[cur_index]
   cur_index += 1
  else:
   snake_case				=			max(__a					,   str_eval(__a     )     )
   snake_case				=			n[cur_index : cur_index + 13]
   cur_index += 13
 return largest_product


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








'''simple docstring'''







import argparse
from collections import OrderedDict
from pathlib import Path

import torch

from transformers import (
    VisualBertConfig,
    VisualBertForMultipleChoice,
    VisualBertForPreTraining,
    VisualBertForQuestionAnswering,
    VisualBertForVisualReasoning,
)
from transformers.utils import logging


logging.set_verbosity_info()
_lowercase       						=			logging.get_logger(__name__)

_lowercase       						=			[
    ('bert.bert', 'visual_bert'),
    ('bert.cls', 'cls'),
    ('bert.classifier', 'cls'),
    ('token_type_embeddings_visual', 'visual_token_type_embeddings'),
    ('position_embeddings_visual', 'visual_position_embeddings'),
    ('projection', 'visual_projection'),
]

_lowercase       						=			[
    'nlvr2_coco_pre_trained.th',
    'nlvr2_fine_tuned.th',
    'nlvr2_pre_trained.th',
    'vcr_coco_pre_train.th',
    'vcr_fine_tune.th',
    'vcr_pre_train.th',
    'vqa_coco_pre_trained.th',
    'vqa_fine_tuned.th',
    'vqa_pre_trained.th',
]

def    __UpperCamelCase	(	a    : List[str]     ) ->Optional[int]:
 snake_case				=			torch.load(a					,   map_location='''cpu'''     )
 return sd

def    __UpperCamelCase	(	a    : Optional[int]					,   a    : Union[str, Any]					,   a    : int=rename_keys_prefix     ) ->Tuple:
 snake_case				=			OrderedDict()
 snake_case				=			torch.arange(config.max_position_embeddings     ).expand((1, -1)     )
 # detector_d = OrderedDict()
 for key in d:
  if "detector" in key:
   # detector_d[key.replace('detector.','')] = d[key]
   continue
  snake_case				=			key
  for name_pair in rename_keys_prefix:
   snake_case				=			new_key.replace(name_pair[0]					,   name_pair[1]     )
  snake_case				=			d[key]
  if key == "bert.cls.predictions.decoder.weight":
   # Old bert code didn't have `decoder.bias`, but was added separately
   snake_case				=			new_d['''cls.predictions.bias''']
 return new_d

@torch.no_grad()
def    __UpperCamelCase	(	a    : Optional[int]					,   a    : int     ) ->Union[str, Any]:
 assert (
     checkpoint_path.split('''/'''     )[-1] in ACCEPTABLE_CHECKPOINTS
 ), f"""The checkpoint provided must be in {ACCEPTABLE_CHECKPOINTS}."""

 # Get Config
 if "pre" in checkpoint_path:
  snake_case				=			'''pretraining'''
  if "vcr" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 512}
  elif "vqa_advanced" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 2048}
  elif "vqa" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 2048}
  elif "nlvr" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 1024}
  else:
   raise NotImplementedError(f"""No implementation found for `{checkpoint_path}`."""     )
 else:
  if "vcr" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 512}
   snake_case				=			'''multichoice'''
  elif "vqa_advanced" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 2048}
   snake_case				=			'''vqa_advanced'''
  elif "vqa" in checkpoint_path:
   snake_case				=			{'''visual_embedding_dim''': 2048, '''num_labels''': 3129}
   snake_case				=			'''vqa'''
  elif "nlvr" in checkpoint_path:
   snake_case				=			{
       '''visual_embedding_dim''': 1024,
       '''num_labels''': 2,
   }
   snake_case				=			'''nlvr'''

 snake_case				=			VisualBertConfig(**a     )

 # Load State Dict
 snake_case				=			load_state_dict(a     )

 snake_case				=			get_new_dict(a					,   a     )

 if model_type == "pretraining":
  snake_case				=			VisualBertForPreTraining(a     )
 elif model_type == "vqa":
  snake_case				=			VisualBertForQuestionAnswering(a     )
 elif model_type == "nlvr":
  snake_case				=			VisualBertForVisualReasoning(a     )
 elif model_type == "multichoice":
  snake_case				=			VisualBertForMultipleChoice(a     )

 model.load_state_dict(a     )
 # Save Checkpoints
 Path(a     ).mkdir(exist_ok=a     )
 model.save_pretrained(a     )


if __name__ == "__main__":
   _lowercase       						=			argparse.ArgumentParser()
   # Required parameters
   parser.add_argument('orig_checkpoint_path', type=str, help='A path to .th on local filesystem.')
   parser.add_argument('pytorch_dump_folder_path', type=str, help='Path to the output PyTorch model.')
   _lowercase       						=			parser.parse_args()
   convert_visual_bert_checkpoint(args.orig_checkpoint_path, args.pytorch_dump_folder_path)

