






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


UpperCamelCase							       =    logging.get_logger(__name__)

UpperCamelCase							       =    {
    """salesforce/blip2-opt-2.7b""": """https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json""",
}




class    lowercase_    (A_     ):
      A__	:		Optional[int]       			=				'''blip_2_vision_model'''






      def __init__(    self     ,     a_=1_4_0_8     ,     a_=6_1_4_4     ,     a_=3_9     ,     a_=1_6     ,     a_=2_2_4     ,     a_=1_4     ,     a_="gelu"     ,     a_=0.00_001     ,     a_=0.0     ,     a_=1E-10     ,     a_=True     ,     **a_     ,     )	->Union[str, Any]:







        '''simple docstring'''


        super().__init__(**a_	)

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






      @classmethod
      def 			lowerCamelCase__    (    cls     ,     a_     ,     **a_	)	->Any:







        '''simple docstring'''


        cls._set_token_in_kwargs(a_	)

        _a							=	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":
          _a							=	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    lowercase_    (A_     ):
      A__	:		Any       			=				'''blip_2_qformer'''






      def __init__(    self     ,     a_=3_0_5_2_2     ,     a_=7_6_8     ,     a_=1_2     ,     a_=1_2     ,     a_=3_0_7_2     ,     a_="gelu"     ,     a_=0.1     ,     a_=0.1     ,     a_=5_1_2     ,     a_=0.02     ,     a_=1E-12     ,     a_=0     ,     a_="absolute"     ,     a_=2     ,     a_=1_4_0_8     ,     **a_     ,     )	->Optional[Any]:







        '''simple docstring'''


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

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






      @classmethod
      def 			lowerCamelCase__    (    cls     ,     a_     ,     **a_	)	->Optional[int]:







        '''simple docstring'''


        cls._set_token_in_kwargs(a_	)

        _a							=	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":
          _a							=	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    lowercase_    (A_     ):
      A__	:		int       			=				'''blip-2'''
      A__	:		Optional[int]       			=				True






      def __init__(    self     ,     a_=None     ,     a_=None     ,     a_=None     ,     a_=3_2     ,     **a_	)	->Optional[int]:







        '''simple docstring'''


        super().__init__(**a_	)

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

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

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

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

        _a							=	self.text_config.tie_word_embeddings
        _a							=	self.text_config.is_encoder_decoder

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






      @classmethod
      def 			lowerCamelCase__    (    cls     ,     a_     ,     a_     ,     a_     ,     **a_     ,     )	->Optional[Any]:







        '''simple docstring'''


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






      def 			lowerCamelCase__    (    self	)	->Any:







        '''simple docstring'''


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










"""simple docstring"""




def        lowerCAmelCase (      UpperCamelCase_:							Optional[int]     , UpperCamelCase_:							str					)       ->							List[Any]:







  '''simple docstring'''







  _a							=	(boundary[1] - boundary[0]) / steps
  _a							=	boundary[0]
  _a							=	boundary[1]
  _a							=	make_points(UpperCamelCase_     , UpperCamelCase_     , UpperCamelCase_					)
  _a							=	0.0
  y += (h / 2.0) * f(UpperCamelCase_					)
  for i in x_i:
    # print(i)
    y += h * f(UpperCamelCase_					)
  y += (h / 2.0) * f(UpperCamelCase_					)
  return y






def        lowerCAmelCase (      UpperCamelCase_:							str     , UpperCamelCase_:							Any     , UpperCamelCase_:							Any					)       ->							str:







  '''simple docstring'''







  _a							=	a + h
  while x < (b - h):
    yield x
    _a							=	x + h






def        lowerCAmelCase (      UpperCamelCase_:							List[str]					)       ->							int:  # enter your function here







  '''simple docstring'''







  _a							=	(x - 0) * (x - 0)
  return y






def        lowerCAmelCase (      )       ->							Tuple:







  '''simple docstring'''







  _a							=	0.0  # Lower bound of integration
  _a							=	1.0  # Upper bound of integration
  _a							=	10.0  # define number of steps or resolution
  _a							=	[a, b]  # define boundary of integration
  _a							=	method_a(UpperCamelCase_     , UpperCamelCase_					)
  print(f'''y = {y}'''					)


if __name__ == "__main__":
     main()


