

"""simple docstring"""




import copy
import os
from typing import Union

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


A_							:			Any											= logging.get_logger(__name__)

A_							:			List[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    lowerCamelCase						(_A			):
			lowerCamelCase__   :		int							=							'blip_text_model'

			def __init__(					self				:						List[str]    ,				__UpperCAmelCase				:						int=3_0_5_2_4    ,				__UpperCAmelCase				:						Dict=7_6_8    ,				__UpperCAmelCase				:						Tuple=7_6_8    ,				__UpperCAmelCase				:						str=3_0_7_2    ,				__UpperCAmelCase				:						Optional[int]=7_6_8    ,				__UpperCAmelCase				:						Dict=1_2    ,				__UpperCAmelCase				:						str=8    ,				__UpperCAmelCase				:						int=5_1_2    ,				__UpperCAmelCase				:						List[Any]="gelu"    ,				__UpperCAmelCase				:						List[str]=1e-12    ,				__UpperCAmelCase				:						Optional[Any]=0.0    ,				__UpperCAmelCase				:						Optional[Any]=0.0    ,				__UpperCAmelCase				:						Tuple=0.02    ,				__UpperCAmelCase				:						Dict=3_0_5_2_2    ,				__UpperCAmelCase				:						str=2    ,				__UpperCAmelCase				:						str=0    ,				__UpperCAmelCase				:						Union[str, Any]=1_0_2    ,				__UpperCAmelCase				:						Any=True    ,				__UpperCAmelCase				:						Optional[Any]=True    ,				**__UpperCAmelCase				:						List[str]    ,				)   ->    Tuple:
						super().__init__(
						    pad_token_id=UpperCamelCase__    ,				bos_token_id=UpperCamelCase__    ,				eos_token_id=UpperCamelCase__    ,				sep_token_id=UpperCamelCase__    ,				**UpperCamelCase__    ,				)

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





			@classmethod
			def 					SCREAMING_SNAKE_CASE				(					cls				:						Optional[Any]    ,				__UpperCAmelCase				:						Union[str, os.PathLike]    ,				**__UpperCAmelCase				:						Tuple       )   ->    "PretrainedConfig":
						cls._set_token_in_kwargs(UpperCamelCase__       )

						SCREAMING_SNAKE_CASE__							,		SCREAMING_SNAKE_CASE__								=      cls.get_config_dict(UpperCamelCase__    ,				**UpperCamelCase__       )

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





class    lowerCamelCase						(_A			):
			lowerCamelCase__   :		Dict							=							'blip_vision_model'

			def __init__(					self				:						Dict    ,				__UpperCAmelCase				:						Optional[Any]=7_6_8    ,				__UpperCAmelCase				:						Tuple=3_0_7_2    ,				__UpperCAmelCase				:						Optional[int]=5_1_2    ,				__UpperCAmelCase				:						Optional[Any]=1_2    ,				__UpperCAmelCase				:						List[str]=1_2    ,				__UpperCAmelCase				:						Union[str, Any]=3_8_4    ,				__UpperCAmelCase				:						int=1_6    ,				__UpperCAmelCase				:						int="gelu"    ,				__UpperCAmelCase				:						List[str]=1e-5    ,				__UpperCAmelCase				:						Union[str, Any]=0.0    ,				__UpperCAmelCase				:						Optional[int]=1e-10    ,				**__UpperCAmelCase				:						int    ,				)   ->    List[str]:
						super().__init__(**UpperCamelCase__       )

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





			@classmethod
			def 					SCREAMING_SNAKE_CASE				(					cls				:						Optional[Any]    ,				__UpperCAmelCase				:						Union[str, os.PathLike]    ,				**__UpperCAmelCase				:						Union[str, Any]       )   ->    "PretrainedConfig":
						cls._set_token_in_kwargs(UpperCamelCase__       )

						SCREAMING_SNAKE_CASE__							,		SCREAMING_SNAKE_CASE__								=      cls.get_config_dict(UpperCamelCase__    ,				**UpperCamelCase__       )

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





class    lowerCamelCase						(_A			):
			lowerCamelCase__   :		Optional[int]							=							'blip'
			lowerCamelCase__   :		Any							=							True

			def __init__(					self				:						int    ,				__UpperCAmelCase				:						int=None    ,				__UpperCAmelCase				:						Any=None    ,				__UpperCAmelCase				:						int=5_1_2    ,				__UpperCAmelCase				:						int=2.6_592    ,				__UpperCAmelCase				:						Optional[int]=2_5_6    ,				**__UpperCAmelCase				:						Dict    ,				)   ->    str:
						super().__init__(**UpperCamelCase__       )

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

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

						SCREAMING_SNAKE_CASE__								=      BlipTextConfig(**UpperCamelCase__       )
						SCREAMING_SNAKE_CASE__								=      BlipVisionConfig(**UpperCamelCase__       )

						SCREAMING_SNAKE_CASE__								=      self.vision_config.hidden_size

						SCREAMING_SNAKE_CASE__								=      projection_dim
						SCREAMING_SNAKE_CASE__								=      logit_scale_init_value
						SCREAMING_SNAKE_CASE__								=      1.0
						SCREAMING_SNAKE_CASE__								=      0.02
						SCREAMING_SNAKE_CASE__								=      image_text_hidden_size

			@classmethod
			def 					SCREAMING_SNAKE_CASE				(					cls				:						Any    ,				__UpperCAmelCase				:						BlipTextConfig    ,				__UpperCAmelCase				:						BlipVisionConfig    ,				**__UpperCAmelCase				:						Optional[int]       )   ->    List[Any]:
						return cls(text_config=text_config.to_dict()    ,				vision_config=vision_config.to_dict()    ,				**UpperCamelCase__       )





			def 					SCREAMING_SNAKE_CASE				(					self				:						Dict       )   ->    List[str]:
						SCREAMING_SNAKE_CASE__								=      copy.deepcopy(self.__dict__       )
						SCREAMING_SNAKE_CASE__								=      self.text_config.to_dict()
						SCREAMING_SNAKE_CASE__								=      self.vision_config.to_dict()
						SCREAMING_SNAKE_CASE__								=      self.__class__.model_type
						return output





"""simple docstring"""




from ..utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
)


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						from ..utils.dummy_pt_objects import *  # noqa F403
else:
						from .scheduling_consistency_models import CMStochasticIterativeScheduler
						from .scheduling_ddim import DDIMScheduler
						from .scheduling_ddim_inverse import DDIMInverseScheduler
						from .scheduling_ddim_parallel import DDIMParallelScheduler
						from .scheduling_ddpm import DDPMScheduler
						from .scheduling_ddpm_parallel import DDPMParallelScheduler
						from .scheduling_deis_multistep import DEISMultistepScheduler
						from .scheduling_dpmsolver_multistep import DPMSolverMultistepScheduler
						from .scheduling_dpmsolver_multistep_inverse import DPMSolverMultistepInverseScheduler
						from .scheduling_dpmsolver_singlestep import DPMSolverSinglestepScheduler
						from .scheduling_euler_ancestral_discrete import EulerAncestralDiscreteScheduler
						from .scheduling_euler_discrete import EulerDiscreteScheduler
						from .scheduling_heun_discrete import HeunDiscreteScheduler
						from .scheduling_ipndm import IPNDMScheduler
						from .scheduling_k_dpm_2_ancestral_discrete import KDPMaAncestralDiscreteScheduler
						from .scheduling_k_dpm_2_discrete import KDPMaDiscreteScheduler
						from .scheduling_karras_ve import KarrasVeScheduler
						from .scheduling_pndm import PNDMScheduler
						from .scheduling_repaint import RePaintScheduler
						from .scheduling_sde_ve import ScoreSdeVeScheduler
						from .scheduling_sde_vp import ScoreSdeVpScheduler
						from .scheduling_unclip import UnCLIPScheduler
						from .scheduling_unipc_multistep import UniPCMultistepScheduler
						from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin
						from .scheduling_vq_diffusion import VQDiffusionScheduler

try:
						if not is_flax_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						from ..utils.dummy_flax_objects import *  # noqa F403
else:
						from .scheduling_ddim_flax import FlaxDDIMScheduler
						from .scheduling_ddpm_flax import FlaxDDPMScheduler
						from .scheduling_dpmsolver_multistep_flax import FlaxDPMSolverMultistepScheduler
						from .scheduling_karras_ve_flax import FlaxKarrasVeScheduler
						from .scheduling_lms_discrete_flax import FlaxLMSDiscreteScheduler
						from .scheduling_pndm_flax import FlaxPNDMScheduler
						from .scheduling_sde_ve_flax import FlaxScoreSdeVeScheduler
						from .scheduling_utils_flax import (
						    FlaxKarrasDiffusionSchedulers,
						    FlaxSchedulerMixin,
						    FlaxSchedulerOutput,
						    broadcast_to_shape_from_left,
						)


try:
						if not (is_torch_available() and is_scipy_available()):
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						from ..utils.dummy_torch_and_scipy_objects import *  # noqa F403
else:
						from .scheduling_lms_discrete import LMSDiscreteScheduler

try:
						if not (is_torch_available() and is_torchsde_available()):
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						from ..utils.dummy_torch_and_torchsde_objects import *  # noqa F403
else:
						from .scheduling_dpmsolver_sde import DPMSolverSDEScheduler


