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

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




class 		a_						( UpperCAmelCase_	):
    a      :				List[Any]     =				'blip_2_vision_model'







    def __init__(			self			:       List[str]     ,					__UpperCamelCase			:       str=14_08     ,					__UpperCamelCase			:       Any=61_44     ,					__UpperCamelCase			:       List[Any]=39     ,					__UpperCamelCase			:       Optional[int]=16     ,					__UpperCamelCase			:       Optional[Any]=2_24     ,					__UpperCamelCase			:       Tuple=14     ,					__UpperCamelCase			:       Union[str, Any]="gelu"     ,					__UpperCamelCase			:       List[Any]=0.0_0_0_0_1     ,					__UpperCamelCase			:       List[str]=0.0     ,					__UpperCamelCase			:       str=1e-10     ,					__UpperCamelCase			:       Union[str, Any]=True     ,					**__UpperCamelCase			:       str     ,					)		->Optional[int]:






        '''simple docstring'''






        super().__init__(**_lowercase     )

        _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      _snake_case					(			cls			:       Any     ,					__UpperCamelCase			:       int     ,					**__UpperCamelCase			:       Dict     )		->"PretrainedConfig":






        '''simple docstring'''






        cls._set_token_in_kwargs(_lowercase     )

        _UpperCAmelCase          =   cls.get_config_dict(_lowercase     ,					**_lowercase     )

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







class 		a_						( UpperCAmelCase_	):
    a      :				int     =				'blip_2_qformer'







    def __init__(			self			:       List[Any]     ,					__UpperCamelCase			:       Union[str, Any]=3_05_22     ,					__UpperCamelCase			:       Union[str, Any]=7_68     ,					__UpperCamelCase			:       Union[str, Any]=12     ,					__UpperCamelCase			:       List[Any]=12     ,					__UpperCamelCase			:       Union[str, Any]=30_72     ,					__UpperCamelCase			:       Tuple="gelu"     ,					__UpperCamelCase			:       Union[str, Any]=0.1     ,					__UpperCamelCase			:       str=0.1     ,					__UpperCamelCase			:       List[str]=5_12     ,					__UpperCamelCase			:       List[str]=0.0_2     ,					__UpperCamelCase			:       Tuple=1e-12     ,					__UpperCamelCase			:       str=0     ,					__UpperCamelCase			:       Tuple="absolute"     ,					__UpperCamelCase			:       str=2     ,					__UpperCamelCase			:       int=14_08     ,					**__UpperCamelCase			:       str     ,					)		->Any:






        '''simple docstring'''






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

        _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      _snake_case					(			cls			:       int     ,					__UpperCamelCase			:       str     ,					**__UpperCamelCase			:       List[Any]     )		->"PretrainedConfig":






        '''simple docstring'''






        cls._set_token_in_kwargs(_lowercase     )

        _UpperCAmelCase          =   cls.get_config_dict(_lowercase     ,					**_lowercase     )

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







class 		a_						( UpperCAmelCase_	):
    a      :				Optional[Any]     =				'blip-2'
    a      :				str     =				True







    def __init__(			self			:       Dict     ,					__UpperCamelCase			:       Union[str, Any]=None     ,					__UpperCamelCase			:       int=None     ,					__UpperCamelCase			:       Optional[Any]=None     ,					__UpperCamelCase			:       Dict=32     ,					**__UpperCamelCase			:       Union[str, Any]     )		->int:






        '''simple docstring'''






        super().__init__(**_lowercase     )

        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(**_lowercase     )
        _UpperCAmelCase          =   BlipaQFormerConfig(**_lowercase     )
        _UpperCAmelCase          =   text_config['model_type'] if 'model_type' in text_config else 'opt'
        _UpperCAmelCase          =   CONFIG_MAPPING[text_model_type](**_lowercase     )

        _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.0_2







    @classmethod
    def      _snake_case					(			cls			:       Union[str, Any]     ,					__UpperCamelCase			:       Union[str, Any]     ,					__UpperCamelCase			:       Dict     ,					__UpperCamelCase			:       List[Any]     ,					**__UpperCamelCase			:       List[str]     ,					)		->Optional[int]:






        '''simple docstring'''






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







    def      _snake_case					(			self			:       List[str]     )		->Any:






        '''simple docstring'''






        _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

"""simple docstring"""



from __future__ import annotations


def  _UpperCamelCase	(						_A      )    ->  None:





    """simple docstring"""

    create_state_space_tree(_A					,      []					,      0					,      [0 for i in range(len(_A      )      )]      )


def  _UpperCamelCase	(						_A					,      _A					,      _A					,      _A					,      )    ->  None:





    """simple docstring"""

    if index == len(_A      ):
        print(_A      )
        return

    for i in range(len(_A      )      ):
        if not index_used[i]:
            current_sequence.append(sequence[i]      )
            _UpperCAmelCase          =   True
            create_state_space_tree(_A					,      _A					,      index + 1					,      _A      )
            current_sequence.pop()
            _UpperCAmelCase          =   False
a					:	list[int | str]							=		[3, 1, 2, 4]
generate_all_permutations(sequence)

a					:	list[int | str]							=		["A", "B", "C"]







generate_all_permutations(sequence_a)