





'''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


a__							:							str =logging.get_logger(__name__)

a__							:							List[str] ={
    """salesforce/blip2-opt-2.7b""": """https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json""",
}

class      snake_case     (    __lowerCamelCase       ):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_	:					str					="blip_2_vision_model"






 def __init__(       self       :							List[str]							,	__A       :							int=1_4_0_8							,	__A       :							Optional[Any]=6_1_4_4							,	__A       :							List[str]=3_9							,	__A       :							Dict=1_6							,	__A       :							int=2_2_4							,	__A       :							Optional[Any]=1_4							,	__A       :							Optional[Any]="gelu"							,	__A       :							int=0.0_0001							,	__A       :							Optional[Any]=0.0							,	__A       :							Union[str, Any]=1e-10							,	__A       :							str=True							,	**__A       :							str							,	):
        super().__init__(**__A	)

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






 @classmethod
 def        _lowerCamelCase					(       cls       :							Optional[Any]							,	__A       :							str							,	**__A       :							Tuple	):
        cls._set_token_in_kwargs(__A	)

        __UpperCamelCase       =  cls.get_config_dict(__A							,	**__A	)

        # get the vision config dict if we are loading from Blip2Config
        if config_dict.get('model_type'	) == "blip-2":
               __UpperCamelCase       =  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      snake_case     (    __lowerCamelCase       ):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_	:					List[str]					="blip_2_qformer"






 def __init__(       self       :							Optional[Any]							,	__A       :							str=3_0_5_2_2							,	__A       :							int=7_6_8							,	__A       :							int=1_2							,	__A       :							str=1_2							,	__A       :							Optional[Any]=3_0_7_2							,	__A       :							Optional[int]="gelu"							,	__A       :							List[Any]=0.1							,	__A       :							Dict=0.1							,	__A       :							List[str]=5_1_2							,	__A       :							List[Any]=0.02							,	__A       :							Dict=1e-12							,	__A       :							Optional[int]=0							,	__A       :							List[Any]="absolute"							,	__A       :							Tuple=2							,	__A       :							Tuple=1_4_0_8							,	**__A       :							Dict							,	):
        super().__init__(pad_token_id=__A							,	**__A	)

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






 @classmethod
 def        _lowerCamelCase					(       cls       :							int							,	__A       :							Any							,	**__A       :							Union[str, Any]	):
        cls._set_token_in_kwargs(__A	)

        __UpperCamelCase       =  cls.get_config_dict(__A							,	**__A	)

        # get the qformer config dict if we are loading from Blip2Config
        if config_dict.get('model_type'	) == "blip-2":
               __UpperCamelCase       =  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(__A							,	**__A	)






class      snake_case     (    __lowerCamelCase       ):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_	:					Optional[int]					="blip-2"
 SCREAMING_SNAKE_CASE_	:					Optional[Any]					=True






 def __init__(       self       :							str							,	__A       :							Dict=None							,	__A       :							Any=None							,	__A       :							Optional[int]=None							,	__A       :							Optional[int]=3_2							,	**__A       :							List[Any]	):
        super().__init__(**__A	)

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

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

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

        __UpperCamelCase       =  BlipaVisionConfig(**__A	)
        __UpperCamelCase       =  BlipaQFormerConfig(**__A	)
        __UpperCamelCase       =  text_config["""model_type"""] if """model_type""" in text_config else """opt"""
        __UpperCamelCase       =  CONFIG_MAPPING[text_model_type](**__A	)

        __UpperCamelCase       =  self.text_config.tie_word_embeddings
        __UpperCamelCase       =  self.text_config.is_encoder_decoder

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






 @classmethod
 def        _lowerCamelCase					(       cls       :							Optional[int]							,	__A       :							Optional[int]							,	__A       :							List[Any]							,	__A       :							Any							,	**__A       :							Optional[int]							,	):
        return cls(
            vision_config=vision_config.to_dict()							,	qformer_config=qformer_config.to_dict()							,	text_config=text_config.to_dict()							,	**__A							,	)






 def        _lowerCamelCase					(       self       :							int	):
        __UpperCamelCase       =  copy.deepcopy(self.__dict__	)
        __UpperCamelCase       =  self.vision_config.to_dict()
        __UpperCamelCase       =  self.qformer_config.to_dict()
        __UpperCamelCase       =  self.text_config.to_dict()
        __UpperCamelCase       =  self.__class__.model_type
        return output


def 						_snake_case(  SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				) ->    List[str]:
       if index == r:
              for j in range(SCREAMING_SNAKE_CASE__				):
                     print(data[j]					,	end=""" """				)
              print(""" """				)
              return
       #  When no more elements are there to put in data[]
       if i >= n:
              return
       # current is included, put next at next location
       lowercase							:     Tuple       	=      arr[i]
       combination_util(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	index + 1					,	SCREAMING_SNAKE_CASE__					,	i + 1				)
       # current is excluded, replace it with
       # next (Note that i+1 is passed, but
       # index is not changed)
       combination_util(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	i + 1				)
       # The main function that prints all combinations
       # of size r in arr[] of size n. This function
       # mainly uses combinationUtil()







def 						_snake_case(  SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				) ->    List[str]:
       # A temporary array to store all combination one by one
       lowercase							:     Optional[int]       	=      [0] * r
       # Print all combination using temporary array 'data[]'
       combination_util(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	0					,	SCREAMING_SNAKE_CASE__					,	0				)


if __name__ == "__main__":
  # Driver code to check the function above
  lowercase  :					int						    =							[10, 20, 30, 40, 50]
  print_combination(arr, len(arr), 3)
  # This code is contributed by Ambuj sahu
