"""simple docstring"""




import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


__lowerCAmelCase    :							List[str]													=						logging.get_logger(__name__)

__lowerCAmelCase    :							List[str]													=						{
    "Salesforce/instruct-blip-flan-t5": "https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json",
}

class       a_      (     __UpperCamelCase			):
					UpperCamelCase_ :	Dict			=    "instructblip_vision_model"




					def __init__(	self						:     Optional[int]  ,						snake_case__						:     Optional[Any]=1408  ,						snake_case__						:     List[str]=6144  ,						snake_case__						:     Optional[Any]=39  ,						snake_case__						:     Optional[int]=16  ,						snake_case__						:     List[str]=224  ,						snake_case__						:     Any=14  ,						snake_case__						:     Any="gelu"  ,						snake_case__						:     List[str]=1E-6  ,						snake_case__						:     List[str]=0.0  ,						snake_case__						:     Optional[int]=1E-10  ,						snake_case__						:     int=True  ,						**snake_case__						:     int  ,						):
							super().__init__(**snake_case__     )

							lowerCAmelCase__        =   hidden_size
							lowerCAmelCase__        =   intermediate_size
							lowerCAmelCase__        =   num_hidden_layers
							lowerCAmelCase__        =   num_attention_heads
							lowerCAmelCase__        =   patch_size
							lowerCAmelCase__        =   image_size
							lowerCAmelCase__        =   initializer_range
							lowerCAmelCase__        =   attention_dropout
							lowerCAmelCase__        =   layer_norm_eps
							lowerCAmelCase__        =   hidden_act
							lowerCAmelCase__        =   qkv_bias




					@classmethod
					def 						_SCREAMING_SNAKE_CASE						(	cls						:     Optional[Any]  ,						snake_case__						:     Union[str, os.PathLike]  ,						**snake_case__						:     Dict     ):
							cls._set_token_in_kwargs(snake_case__     )

							lowerCAmelCase__   ,					lowerCAmelCase__        =   cls.get_config_dict(snake_case__  ,						**snake_case__     )

							# get the vision config dict if we are loading from InstructBlipConfig
							if config_dict.get("""model_type"""     ) == "instructblip":
									lowerCAmelCase__        =   config_dict["""vision_config"""]

							if "model_type" in config_dict and hasattr(cls  ,						"""model_type"""     ) and config_dict["model_type"] != cls.model_type:
									logger.warning(
									    F"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
									    F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""     )

							return cls.from_dict(snake_case__  ,						**snake_case__     )

class       a_      (     __UpperCamelCase			):
					UpperCamelCase_ :	int			=    "instructblip_qformer"




					def __init__(	self						:     Tuple  ,						snake_case__						:     Optional[int]=30522  ,						snake_case__						:     Dict=768  ,						snake_case__						:     Dict=12  ,						snake_case__						:     Dict=12  ,						snake_case__						:     List[Any]=3072  ,						snake_case__						:     Any="gelu"  ,						snake_case__						:     str=0.1  ,						snake_case__						:     int=0.1  ,						snake_case__						:     Any=512  ,						snake_case__						:     List[str]=0.02  ,						snake_case__						:     Any=1E-12  ,						snake_case__						:     Optional[int]=0  ,						snake_case__						:     str="absolute"  ,						snake_case__						:     Any=2  ,						snake_case__						:     Any=1408  ,						**snake_case__						:     Any  ,						):
							super().__init__(pad_token_id=snake_case__  ,						**snake_case__     )

							lowerCAmelCase__        =   vocab_size
							lowerCAmelCase__        =   hidden_size
							lowerCAmelCase__        =   num_hidden_layers
							lowerCAmelCase__        =   num_attention_heads
							lowerCAmelCase__        =   hidden_act
							lowerCAmelCase__        =   intermediate_size
							lowerCAmelCase__        =   hidden_dropout_prob
							lowerCAmelCase__        =   attention_probs_dropout_prob
							lowerCAmelCase__        =   max_position_embeddings
							lowerCAmelCase__        =   initializer_range
							lowerCAmelCase__        =   layer_norm_eps
							lowerCAmelCase__        =   position_embedding_type
							lowerCAmelCase__        =   cross_attention_frequency
							lowerCAmelCase__        =   encoder_hidden_size




					@classmethod
					def 						_SCREAMING_SNAKE_CASE						(	cls						:     Any  ,						snake_case__						:     Union[str, os.PathLike]  ,						**snake_case__						:     List[str]     ):
							cls._set_token_in_kwargs(snake_case__     )

							lowerCAmelCase__   ,					lowerCAmelCase__        =   cls.get_config_dict(snake_case__  ,						**snake_case__     )

							# get the qformer config dict if we are loading from InstructBlipConfig
							if config_dict.get("""model_type"""     ) == "instructblip":
									lowerCAmelCase__        =   config_dict["""qformer_config"""]

							if "model_type" in config_dict and hasattr(cls  ,						"""model_type"""     ) and config_dict["model_type"] != cls.model_type:
									logger.warning(
									    F"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
									    F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""     )

							return cls.from_dict(snake_case__  ,						**snake_case__     )

class       a_      (     __UpperCamelCase			):
					UpperCamelCase_ :	Union[str, Any]			=    "instructblip"
					UpperCamelCase_ :	Optional[Any]			=    True




					def __init__(	self						:     Dict  ,						snake_case__						:     str=None  ,						snake_case__						:     str=None  ,						snake_case__						:     Optional[int]=None  ,						snake_case__						:     List[str]=32  ,						**snake_case__						:     int     ):
							super().__init__(**snake_case__     )

							if vision_config is None:
									lowerCAmelCase__        =   {}
									logger.info("""vision_config is None. initializing the InstructBlipVisionConfig with default values."""     )

							if qformer_config is None:
									lowerCAmelCase__        =   {}
									logger.info("""qformer_config is None. Initializing the InstructBlipQFormerConfig with default values."""     )

							if text_config is None:
									lowerCAmelCase__        =   {}
									logger.info("""text_config is None. Initializing the text config with default values (`OPTConfig`)."""     )

							lowerCAmelCase__        =   InstructBlipVisionConfig(**snake_case__     )
							lowerCAmelCase__        =   InstructBlipQFormerConfig(**snake_case__     )
							lowerCAmelCase__        =   text_config["""model_type"""] if """model_type""" in text_config else """opt"""
							lowerCAmelCase__        =   CONFIG_MAPPING[text_model_type](**snake_case__     )

							lowerCAmelCase__        =   self.text_config.tie_word_embeddings
							lowerCAmelCase__        =   self.text_config.is_encoder_decoder

							lowerCAmelCase__        =   num_query_tokens
							lowerCAmelCase__        =   self.vision_config.hidden_size
							lowerCAmelCase__        =   self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
							lowerCAmelCase__        =   1.0
							lowerCAmelCase__        =   0.02




					@classmethod
					def 						_SCREAMING_SNAKE_CASE						(	cls						:     List[Any]  ,						snake_case__						:     InstructBlipVisionConfig  ,						snake_case__						:     InstructBlipQFormerConfig  ,						snake_case__						:     PretrainedConfig  ,						**snake_case__						:     Union[str, Any]  ,						):
							return cls(
							    vision_config=vision_config.to_dict()  ,						qformer_config=qformer_config.to_dict()  ,						text_config=text_config.to_dict()  ,						**snake_case__  ,						)




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any     ):
							lowerCAmelCase__        =   copy.deepcopy(self.__dict__     )
							lowerCAmelCase__        =   self.vision_config.to_dict()
							lowerCAmelCase__        =   self.qformer_config.to_dict()
							lowerCAmelCase__        =   self.text_config.to_dict()
							lowerCAmelCase__        =   self.__class__.model_type
							return output





"""simple docstring"""




import os







def 							_UpperCAmelCase		(       ):





		"""simple docstring"""




		lowerCAmelCase__        =   os.path.dirname(os.path.realpath(lowerCamelCase__     )     )
		lowerCAmelCase__        =   os.path.join(lowerCamelCase__			,  """triangle.txt"""     )

		with open(lowerCamelCase__     ) as f:
				lowerCAmelCase__        =   f.readlines()

		lowerCAmelCase__        =   []
		for line in triangle:
				lowerCAmelCase__        =   []
				for number in line.strip().split(""" """     ):
						numbers_from_line.append(int(lowerCamelCase__     )     )
				a.append(lowerCamelCase__     )

		for i in range(1			,  len(lowerCamelCase__     )     ):
				for j in range(len(a[i]     )     ):
						lowerCAmelCase__        =   a[i - 1][j] if j != len(a[i - 1]     ) else 0
						lowerCAmelCase__        =   a[i - 1][j - 1] if j > 0 else 0
						a[i][j] += max(lowerCamelCase__			,  lowerCamelCase__     )
		return max(a[-1]     )


if __name__ == "__main__":
			print(solution())




