






'''simple docstring'''







import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase     :   Tuple	      =		logging.get_logger(__name__)

UpperCamelCase     :   Any	      =		{
    'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json',
    'Salesforce/blip-vqa-capfit-large': (
        'https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-base': (
        'https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-large': (
        'https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json'
    ),
    'Salesforce/blip-itm-base-coco': 'https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json',
    'Salesforce/blip-itm-large-coco': 'https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json',
    'Salesforce/blip-itm-base-flikr': 'https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json',
    'Salesforce/blip-itm-large-flikr': (
        'https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json'
    ),
}




class 		UpperCamelCase__     (a      ):




		'''simple docstring'''





		_UpperCamelCase						=       'blip_text_model'






		def __init__(   self ,_lowerCAmelCase=3_05_24 ,_lowerCAmelCase=7_68 ,_lowerCAmelCase=7_68 ,_lowerCAmelCase=30_72 ,_lowerCAmelCase=7_68 ,_lowerCAmelCase=12 ,_lowerCAmelCase=8 ,_lowerCAmelCase=5_12 ,_lowerCAmelCase="gelu" ,_lowerCAmelCase=1E-12 ,_lowerCAmelCase=0.0 ,_lowerCAmelCase=0.0 ,_lowerCAmelCase=0.02 ,_lowerCAmelCase=3_05_22 ,_lowerCAmelCase=2 ,_lowerCAmelCase=0 ,_lowerCAmelCase=1_02 ,_lowerCAmelCase=True ,_lowerCAmelCase=True ,**_lowerCAmelCase ,):
								super().__init__(
								    pad_token_id=_lowerCAmelCase ,bos_token_id=_lowerCAmelCase ,eos_token_id=_lowerCAmelCase ,sep_token_id=_lowerCAmelCase ,**_lowerCAmelCase ,)

								lowerCamelCase__								=	vocab_size
								lowerCamelCase__								=	hidden_size
								lowerCamelCase__								=	encoder_hidden_size
								lowerCamelCase__								=	intermediate_size
								lowerCamelCase__								=	projection_dim
								lowerCamelCase__								=	hidden_dropout_prob
								lowerCamelCase__								=	num_hidden_layers
								lowerCamelCase__								=	num_attention_heads
								lowerCamelCase__								=	max_position_embeddings
								lowerCamelCase__								=	layer_norm_eps
								lowerCamelCase__								=	hidden_act
								lowerCamelCase__								=	initializer_range
								lowerCamelCase__								=	attention_probs_dropout_prob
								lowerCamelCase__								=	is_decoder
								lowerCamelCase__								=	use_cache






		@classmethod
		def       UpperCamelCase_       (   cls ,_lowerCAmelCase ,**_lowerCAmelCase							):
								cls._set_token_in_kwargs(_lowerCAmelCase							)

								lowerCamelCase__							,      lowerCamelCase__								=	cls.get_config_dict(_lowerCAmelCase ,**_lowerCAmelCase							)

								# get the text config dict if we are loading from BlipConfig
								if config_dict.get("""model_type"""							) == "blip":
														lowerCamelCase__								=	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(_lowerCAmelCase ,**_lowerCAmelCase							)




class 		UpperCamelCase__     (a      ):




		'''simple docstring'''





		_UpperCamelCase						=       'blip_vision_model'






		def __init__(   self ,_lowerCAmelCase=7_68 ,_lowerCAmelCase=30_72 ,_lowerCAmelCase=5_12 ,_lowerCAmelCase=12 ,_lowerCAmelCase=12 ,_lowerCAmelCase=3_84 ,_lowerCAmelCase=16 ,_lowerCAmelCase="gelu" ,_lowerCAmelCase=1E-5 ,_lowerCAmelCase=0.0 ,_lowerCAmelCase=1E-10 ,**_lowerCAmelCase ,):
								super().__init__(**_lowerCAmelCase							)

								lowerCamelCase__								=	hidden_size
								lowerCamelCase__								=	intermediate_size
								lowerCamelCase__								=	projection_dim
								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






		@classmethod
		def       UpperCamelCase_       (   cls ,_lowerCAmelCase ,**_lowerCAmelCase							):
								cls._set_token_in_kwargs(_lowerCAmelCase							)

								lowerCamelCase__							,      lowerCamelCase__								=	cls.get_config_dict(_lowerCAmelCase ,**_lowerCAmelCase							)

								# get the vision config dict if we are loading from BlipConfig
								if config_dict.get("""model_type"""							) == "blip":
														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(_lowerCAmelCase ,**_lowerCAmelCase							)




class 		UpperCamelCase__     (a      ):




		'''simple docstring'''





		_UpperCamelCase						=       'blip'
		_UpperCamelCase						=       True






		def __init__(   self ,_lowerCAmelCase=None ,_lowerCAmelCase=None ,_lowerCAmelCase=5_12 ,_lowerCAmelCase=2.6592 ,_lowerCAmelCase=2_56 ,**_lowerCAmelCase ,):
								super().__init__(**_lowerCAmelCase							)

								if text_config is None:
														lowerCamelCase__								=	{}
														logger.info("""`text_config` is `None`. Initializing the `BlipTextConfig` with default values."""							)

								if vision_config is None:
														lowerCamelCase__								=	{}
														logger.info("""`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values."""							)

								lowerCamelCase__								=	BlipTextConfig(**_lowerCAmelCase							)
								lowerCamelCase__								=	BlipVisionConfig(**_lowerCAmelCase							)

								lowerCamelCase__								=	self.vision_config.hidden_size

								lowerCamelCase__								=	projection_dim
								lowerCamelCase__								=	logit_scale_init_value
								lowerCamelCase__								=	1.0
								lowerCamelCase__								=	0.02
								lowerCamelCase__								=	image_text_hidden_size






		@classmethod
		def       UpperCamelCase_       (   cls ,_lowerCAmelCase ,_lowerCAmelCase ,**_lowerCAmelCase							):
								return cls(text_config=text_config.to_dict() ,vision_config=vision_config.to_dict() ,**_lowerCAmelCase							)






		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	copy.deepcopy(self.__dict__							)
								lowerCamelCase__								=	self.text_config.to_dict()
								lowerCamelCase__								=	self.vision_config.to_dict()
								lowerCamelCase__								=	self.__class__.model_type
								return output


'''simple docstring'''


from collections.abc import Sequence





def    lowerCAmelCase       (		UpperCamelCase__					: Sequence[float]     ,       UpperCamelCase__					: bool = False							):


	"""simple docstring"""
	if not arr:
		return 0

	__UpperCAmelCase      					=      0 if allow_empty_subarrays else float('''-inf'''							)
	__UpperCAmelCase      					=      0.0
	for num in arr:
		__UpperCAmelCase      					=      max(0 if allow_empty_subarrays else num     ,       curr_sum + num							)
		__UpperCAmelCase      					=      max(UpperCamelCase__     ,       UpperCamelCase__							)

	return max_sum


if __name__ == "__main__":
					from doctest import testmod

					testmod()

					__lowerCAmelCase						:							int    							=						[-2, 1, -3, 4, -1, 2, 1, -5, 4]
					print(F"""{max_subarray_sum(nums) = }""")
