
"""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__							=				logging.get_logger(__name__)

lowerCAmelCase__							=				{
    "Salesforce/instruct-blip-flan-t5": "https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json",
}





class  snake_case     (							__UpperCAmelCase   ):
							UpperCAmelCase__						     =      '''instructblip_vision_model'''

							def __init__(self       ,       SCREAMING_SNAKE_CASE_=14_08       ,       SCREAMING_SNAKE_CASE_=61_44       ,       SCREAMING_SNAKE_CASE_=39       ,       SCREAMING_SNAKE_CASE_=16       ,       SCREAMING_SNAKE_CASE_=2_24       ,       SCREAMING_SNAKE_CASE_=14       ,       SCREAMING_SNAKE_CASE_="gelu"       ,       SCREAMING_SNAKE_CASE_=1e-6       ,       SCREAMING_SNAKE_CASE_=0.0       ,       SCREAMING_SNAKE_CASE_=1e-1_0       ,       SCREAMING_SNAKE_CASE_=True       ,       **SCREAMING_SNAKE_CASE_       ,       ):

									"""simple docstring"""







									super().__init__(**lowerCAmelCase_    )

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







							@classmethod
							def _lowercase					(cls       ,       SCREAMING_SNAKE_CASE_       ,       **SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									cls._set_token_in_kwargs(lowerCAmelCase_    )

									SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_   = cls.get_config_dict(lowerCAmelCase_       ,       **lowerCAmelCase_    )

									# get the vision config dict if we are loading from InstructBlipConfig
									if config_dict.get('''model_type'''    ) == "instructblip":
											SCREAMING_SNAKE_CASE_   = 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  snake_case     (							__UpperCAmelCase   ):
							UpperCAmelCase__						     =      '''instructblip_qformer'''

							def __init__(self       ,       SCREAMING_SNAKE_CASE_=3_05_22       ,       SCREAMING_SNAKE_CASE_=7_68       ,       SCREAMING_SNAKE_CASE_=12       ,       SCREAMING_SNAKE_CASE_=12       ,       SCREAMING_SNAKE_CASE_=30_72       ,       SCREAMING_SNAKE_CASE_="gelu"       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=5_12       ,       SCREAMING_SNAKE_CASE_=0.02       ,       SCREAMING_SNAKE_CASE_=1e-1_2       ,       SCREAMING_SNAKE_CASE_=0       ,       SCREAMING_SNAKE_CASE_="absolute"       ,       SCREAMING_SNAKE_CASE_=2       ,       SCREAMING_SNAKE_CASE_=14_08       ,       **SCREAMING_SNAKE_CASE_       ,       ):

									"""simple docstring"""







									super().__init__(pad_token_id=lowerCAmelCase_       ,       **lowerCAmelCase_    )

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







							@classmethod
							def _lowercase					(cls       ,       SCREAMING_SNAKE_CASE_       ,       **SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									cls._set_token_in_kwargs(lowerCAmelCase_    )

									SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_   = cls.get_config_dict(lowerCAmelCase_       ,       **lowerCAmelCase_    )

									# get the qformer config dict if we are loading from InstructBlipConfig
									if config_dict.get('''model_type'''    ) == "instructblip":
											SCREAMING_SNAKE_CASE_   = 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(lowerCAmelCase_       ,       **lowerCAmelCase_    )







class  snake_case     (							__UpperCAmelCase   ):
							UpperCAmelCase__						     =      '''instructblip'''
							UpperCAmelCase__						     =      True

							def __init__(self       ,       SCREAMING_SNAKE_CASE_=None       ,       SCREAMING_SNAKE_CASE_=None       ,       SCREAMING_SNAKE_CASE_=None       ,       SCREAMING_SNAKE_CASE_=32       ,       **SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									super().__init__(**lowerCAmelCase_    )

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

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

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

									SCREAMING_SNAKE_CASE_   = InstructBlipVisionConfig(**lowerCAmelCase_    )
									SCREAMING_SNAKE_CASE_   = InstructBlipQFormerConfig(**lowerCAmelCase_    )
									SCREAMING_SNAKE_CASE_   = text_config['''model_type'''] if '''model_type''' in text_config else '''opt'''
									SCREAMING_SNAKE_CASE_   = CONFIG_MAPPING[text_model_type](**lowerCAmelCase_    )

									SCREAMING_SNAKE_CASE_   = self.text_config.tie_word_embeddings
									SCREAMING_SNAKE_CASE_   = self.text_config.is_encoder_decoder

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

							@classmethod
							def _lowercase					(cls       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       **SCREAMING_SNAKE_CASE_       ,       ):

									"""simple docstring"""







									return cls(
									    vision_config=vision_config.to_dict()       ,       qformer_config=qformer_config.to_dict()       ,       text_config=text_config.to_dict()       ,       **lowerCAmelCase_       ,       )







							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_   = copy.deepcopy(self.__dict__    )
									SCREAMING_SNAKE_CASE_   = self.vision_config.to_dict()
									SCREAMING_SNAKE_CASE_   = self.qformer_config.to_dict()
									SCREAMING_SNAKE_CASE_   = self.text_config.to_dict()
									SCREAMING_SNAKE_CASE_   = self.__class__.model_type
									return output

"""simple docstring"""




from __future__ import annotations



def        _lowerCamelCase ( __a,							__a    ):
		SCREAMING_SNAKE_CASE_						 = 0
		SCREAMING_SNAKE_CASE_						 = len(__a    ) - 1

		while i < j:
				if nums[i] + nums[j] == target:
						return [i, j]
				elif nums[i] + nums[j] < target:
						SCREAMING_SNAKE_CASE_						 = i + 1
				else:
						SCREAMING_SNAKE_CASE_						 = j - 1

		return []


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(f'''{two_pointer([2, 7, 11, 15], 9) = }''')