





import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
    from ...processing_utils import ProcessorMixin
    from ...utils import TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__lowerCamelCase	:					str			  =					logging.get_logger(__name__)

__lowerCamelCase	:					Dict			  =					{
    """google/owlvit-base-patch32""": """https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json""",
    """google/owlvit-base-patch16""": """https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json""",
    """google/owlvit-large-patch14""": """https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json""",
}



class  A__       (	__snake_case      ):
      _UpperCAmelCase     :List[Any]						   =       'owlvit_text_model'





      def __init__(			self	,							A_=4_9408	,							A_=512	,							A_=2048	,							A_=12	,							A_=8	,							A_=16	,							A_="quick_gelu"	,							A_=1e-5	,							A_=0.0	,							A_=0.02	,							A_=1.0	,							A_=0	,							A_=4_9406	,							A_=4_9407	,							**A_	,							):
       '''simple docstring'''




       super().__init__(pad_token_id=A_	,							bos_token_id=A_	,							eos_token_id=A_	,							**A_       )

       UpperCamelCase     : List[str]	     =       vocab_size
       UpperCamelCase     : Tuple	     =       hidden_size
       UpperCamelCase     : List[Any]	     =       intermediate_size
       UpperCamelCase     : int	     =       num_hidden_layers
       UpperCamelCase     : Dict	     =       num_attention_heads
       UpperCamelCase     : Tuple	     =       max_position_embeddings
       UpperCamelCase     : Optional[Any]	     =       hidden_act
       UpperCamelCase     : Dict	     =       layer_norm_eps
       UpperCamelCase     : Tuple	     =       attention_dropout
       UpperCamelCase     : Optional[Any]	     =       initializer_range
       UpperCamelCase     : Optional[Any]	     =       initializer_factor





      @classmethod
      def 	__UpperCamelCase(			cls	,							A_	,							**A_       ):
       '''simple docstring'''




       cls._set_token_in_kwargs(A_       )

       UpperCamelCase     ,   UpperCamelCase     : Dict	     =       cls.get_config_dict(A_	,							**A_       )

       # get the text config dict if we are loading from OwlViTConfig
       if config_dict.get("model_type"       ) == "owlvit":
        UpperCamelCase     : Union[str, Any]	     =       config_dict["text_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(A_	,							**A_       )



class  A__       (	__snake_case      ):
      _UpperCAmelCase     :Any						   =       'owlvit_vision_model'





      def __init__(			self	,							A_=768	,							A_=3072	,							A_=12	,							A_=12	,							A_=3	,							A_=768	,							A_=32	,							A_="quick_gelu"	,							A_=1e-5	,							A_=0.0	,							A_=0.02	,							A_=1.0	,							**A_	,							):
       '''simple docstring'''




       super().__init__(**A_       )

       UpperCamelCase     : Any	     =       hidden_size
       UpperCamelCase     : int	     =       intermediate_size
       UpperCamelCase     : int	     =       num_hidden_layers
       UpperCamelCase     : Optional[int]	     =       num_attention_heads
       UpperCamelCase     : List[str]	     =       num_channels
       UpperCamelCase     : List[Any]	     =       image_size
       UpperCamelCase     : str	     =       patch_size
       UpperCamelCase     : Any	     =       hidden_act
       UpperCamelCase     : int	     =       layer_norm_eps
       UpperCamelCase     : List[str]	     =       attention_dropout
       UpperCamelCase     : List[str]	     =       initializer_range
       UpperCamelCase     : Optional[Any]	     =       initializer_factor





      @classmethod
      def 	__UpperCamelCase(			cls	,							A_	,							**A_       ):
       '''simple docstring'''




       cls._set_token_in_kwargs(A_       )

       UpperCamelCase     ,   UpperCamelCase     : Tuple	     =       cls.get_config_dict(A_	,							**A_       )

       # get the vision config dict if we are loading from OwlViTConfig
       if config_dict.get("model_type"       ) == "owlvit":
        UpperCamelCase     : str	     =       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(A_	,							**A_       )



class  A__       (	__snake_case      ):
      _UpperCAmelCase     :Optional[int]						   =       'owlvit'
      _UpperCAmelCase     :str						   =       True





      def __init__(			self	,							A_=None	,							A_=None	,							A_=512	,							A_=2.65_92	,							A_=True	,							**A_	,							):
       '''simple docstring'''




       super().__init__(**A_       )

       if text_config is None:
        UpperCamelCase     : Tuple	     =       {}
        logger.info("text_config is None. Initializing the OwlViTTextConfig with default values."       )

       if vision_config is None:
        UpperCamelCase     : int	     =       {}
        logger.info("vision_config is None. initializing the OwlViTVisionConfig with default values."       )

       UpperCamelCase     : List[str]	     =       OwlViTTextConfig(**A_       )
       UpperCamelCase     : Tuple	     =       OwlViTVisionConfig(**A_       )

       UpperCamelCase     : Optional[Any]	     =       projection_dim
       UpperCamelCase     : int	     =       logit_scale_init_value
       UpperCamelCase     : str	     =       return_dict
       UpperCamelCase     : Tuple	     =       1.0





      @classmethod
      def 	__UpperCamelCase(			cls	,							A_	,							**A_       ):
       '''simple docstring'''




       cls._set_token_in_kwargs(A_       )

       UpperCamelCase     ,   UpperCamelCase     : int	     =       cls.get_config_dict(A_	,							**A_       )

       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(A_	,							**A_       )





      @classmethod
      def 	__UpperCamelCase(			cls	,							A_	,							A_	,							**A_       ):
       '''simple docstring'''




       UpperCamelCase     : int	     =       {}
       UpperCamelCase     : Optional[Any]	     =       text_config
       UpperCamelCase     : Dict	     =       vision_config

       return cls.from_dict(A_	,							**A_       )





      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       UpperCamelCase     : Union[str, Any]	     =       copy.deepcopy(self.__dict__       )
       UpperCamelCase     : Tuple	     =       self.text_config.to_dict()
       UpperCamelCase     : List[str]	     =       self.vision_config.to_dict()
       UpperCamelCase     : List[str]	     =       self.__class__.model_type
       return output



class  A__       (	__snake_case      ):





      @property
      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return OrderedDict(
           [
               ("input_ids", {0: "batch", 1: "sequence"}),
               ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
               ("attention_mask", {0: "batch", 1: "sequence"}),
           ]       )





      @property
      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return OrderedDict(
           [
               ("logits_per_image", {0: "batch"}),
               ("logits_per_text", {0: "batch"}),
               ("text_embeds", {0: "batch"}),
               ("image_embeds", {0: "batch"}),
           ]       )





      @property
      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return 1e-4





      def 	__UpperCamelCase(			self	,							A_	,							A_ = -1	,							A_ = -1	,							A_ = None	,							):
       '''simple docstring'''




       UpperCamelCase     : int	     =       super().generate_dummy_inputs(
           processor.tokenizer	,							batch_size=A_	,							seq_length=A_	,							framework=A_       )
       UpperCamelCase     : List[str]	     =       super().generate_dummy_inputs(
           processor.image_processor	,							batch_size=A_	,							framework=A_       )
       return {**text_input_dict, **image_input_dict}





      @property
      def 	__UpperCamelCase(			self       ):
       '''simple docstring'''




       return 14







import os



def 		A_    (					)						->			int:
 UpperCamelCase     : List[str]	     =       os.path.dirname(os.path.realpath(_lowerCAmelCase					)					)
 UpperCamelCase     : Any	     =       os.path.join(_lowerCAmelCase							,       "triangle.txt"					)

 with open(_lowerCAmelCase					) as f:
  UpperCamelCase     : Optional[Any]	     =       f.readlines()

 UpperCamelCase     : Tuple	     =       []
 for line in triangle:
  UpperCamelCase     : List[str]	     =       []
  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]					)					):
   UpperCamelCase     : List[Any]	     =       a[i - 1][j] if j != len(a[i - 1]					) else 0
   UpperCamelCase     : Dict	     =       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())
