






import copy
import os
from typing import Union

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


lowerCamelCase : Union[str, Any]						   =       logging.get_logger(__name__)

lowerCamelCase : 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			):

					'''simple docstring'''

					_A						:			Union[str, Any]									=      '''blip_text_model'''



					def __init__(  self				:	List[str]		,     __a				:	Tuple=30524		,     __a				:	str=768		,     __a				:	int=768		,     __a				:	Optional[Any]=3072		,     __a				:	int=768		,     __a				:	Optional[Any]=12		,     __a				:	Optional[Any]=8		,     __a				:	str=512		,     __a				:	Dict="gelu"		,     __a				:	List[str]=1E-12		,     __a				:	List[str]=0.0		,     __a				:	Union[str, Any]=0.0		,     __a				:	List[str]=0.02		,     __a				:	Optional[int]=30522		,     __a				:	Optional[Any]=2		,     __a				:	Tuple=0		,     __a				:	str=102		,     __a				:	Union[str, Any]=True		,     __a				:	List[str]=True		,     **__a				:	List[str]		,     )			->  Any:


												"""simple docstring"""

												super().__init__(
												    pad_token_id=__a		,     bos_token_id=__a		,     eos_token_id=__a		,     sep_token_id=__a		,     **__a		,     )

												__lowercase      :							int				=     vocab_size
												__lowercase      :							int				=     hidden_size
												__lowercase      :							Dict				=     encoder_hidden_size
												__lowercase      :							Optional[Any]				=     intermediate_size
												__lowercase      :							List[Any]				=     projection_dim
												__lowercase      :							List[str]				=     hidden_dropout_prob
												__lowercase      :							Dict				=     num_hidden_layers
												__lowercase      :							Any				=     num_attention_heads
												__lowercase      :							Optional[Any]				=     max_position_embeddings
												__lowercase      :							Optional[Any]				=     layer_norm_eps
												__lowercase      :							Tuple				=     hidden_act
												__lowercase      :							Dict				=     initializer_range
												__lowercase      :							Optional[int]				=     attention_probs_dropout_prob
												__lowercase      :							Tuple				=     is_decoder
												__lowercase      :							Dict				=     use_cache



					@classmethod
					def       lowerCAmelCase				(  cls				:	Any		,     __a				:	Union[str, os.PathLike]		,     **__a				:	List[str]							)			->  "PretrainedConfig":


												"""simple docstring"""

												cls._set_token_in_kwargs(__a							)

												__lowercase			,			__lowercase      :							int				=     cls.get_config_dict(__a		,     **__a							)

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







class 		lowerCAmelCase     ( __a			):

					'''simple docstring'''

					_A						:			Union[str, Any]									=      '''blip_vision_model'''



					def __init__(  self				:	List[Any]		,     __a				:	Union[str, Any]=768		,     __a				:	Tuple=3072		,     __a				:	int=512		,     __a				:	Any=12		,     __a				:	Dict=12		,     __a				:	Any=384		,     __a				:	List[Any]=16		,     __a				:	Any="gelu"		,     __a				:	Union[str, Any]=1E-5		,     __a				:	List[str]=0.0		,     __a				:	Union[str, Any]=1E-10		,     **__a				:	int		,     )			->  int:


												"""simple docstring"""

												super().__init__(**__a							)

												__lowercase      :							Tuple				=     hidden_size
												__lowercase      :							Any				=     intermediate_size
												__lowercase      :							Tuple				=     projection_dim
												__lowercase      :							Optional[int]				=     num_hidden_layers
												__lowercase      :							Tuple				=     num_attention_heads
												__lowercase      :							Optional[Any]				=     patch_size
												__lowercase      :							int				=     image_size
												__lowercase      :							int				=     initializer_range
												__lowercase      :							int				=     attention_dropout
												__lowercase      :							Dict				=     layer_norm_eps
												__lowercase      :							List[str]				=     hidden_act



					@classmethod
					def       lowerCAmelCase				(  cls				:	Union[str, Any]		,     __a				:	Union[str, os.PathLike]		,     **__a				:	Optional[int]							)			->  "PretrainedConfig":


												"""simple docstring"""

												cls._set_token_in_kwargs(__a							)

												__lowercase			,			__lowercase      :							Union[str, Any]				=     cls.get_config_dict(__a		,     **__a							)

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

					'''simple docstring'''

					_A						:			Dict									=      '''blip'''
					_A						:			Any									=      True



					def __init__(  self				:	Any		,     __a				:	Union[str, Any]=None		,     __a				:	Optional[int]=None		,     __a				:	Optional[int]=512		,     __a				:	Tuple=2.6592		,     __a				:	Tuple=256		,     **__a				:	str		,     )			->  Tuple:


												"""simple docstring"""

												super().__init__(**__a							)

												if text_config is None:
																			__lowercase      :							Optional[Any]				=     {}
																			logger.info("""`text_config` is `None`. Initializing the `BlipTextConfig` with default values."""							)

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

												__lowercase      :							Optional[Any]				=     BlipTextConfig(**__a							)
												__lowercase      :							Union[str, Any]				=     BlipVisionConfig(**__a							)

												__lowercase      :							Optional[int]				=     self.vision_config.hidden_size

												__lowercase      :							List[str]				=     projection_dim
												__lowercase      :							int				=     logit_scale_init_value
												__lowercase      :							Optional[int]				=     1.0
												__lowercase      :							Dict				=     0.02
												__lowercase      :							Optional[Any]				=     image_text_hidden_size



					@classmethod
					def       lowerCAmelCase				(  cls				:	Any		,     __a				:	BlipTextConfig		,     __a				:	BlipVisionConfig		,     **__a				:	Optional[int]							)			->  Union[str, Any]:


												"""simple docstring"""

												return cls(text_config=text_config.to_dict()		,     vision_config=vision_config.to_dict()		,     **__a							)



					def       lowerCAmelCase				(  self				:	Union[str, Any]							)			->  Union[str, Any]:


												"""simple docstring"""

												__lowercase      :							Tuple				=     copy.deepcopy(self.__dict__							)
												__lowercase      :							Tuple				=     self.text_config.to_dict()
												__lowercase      :							str				=     self.vision_config.to_dict()
												__lowercase      :							Any				=     self.__class__.model_type
												return output







lowerCamelCase : List[str]						   =       '''0.18.2'''

from .configuration_utils import ConfigMixin
from .utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_inflect_available,
    is_invisible_watermark_available,
    is_k_diffusion_available,
    is_k_diffusion_version,
    is_librosa_available,
    is_note_seq_available,
    is_onnx_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
    is_transformers_available,
    is_transformers_version,
    is_unidecode_available,
    logging,
)


try:
	if not is_onnx_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_onnx_objects import *  # noqa F403
else:
	from .pipelines import OnnxRuntimeModel

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_pt_objects import *  # noqa F403
else:
	from .models import (
	    AutoencoderKL,
	    ControlNetModel,
	    ModelMixin,
	    PriorTransformer,
	    TaFilmDecoder,
	    TransformeraDModel,
	    UNetaDModel,
	    UNetaDConditionModel,
	    UNetaDModel,
	    UNetaDConditionModel,
	    VQModel,
	)
	from .optimization import (
	    get_constant_schedule,
	    get_constant_schedule_with_warmup,
	    get_cosine_schedule_with_warmup,
	    get_cosine_with_hard_restarts_schedule_with_warmup,
	    get_linear_schedule_with_warmup,
	    get_polynomial_decay_schedule_with_warmup,
	    get_scheduler,
	)
	from .pipelines import (
	    AudioPipelineOutput,
	    ConsistencyModelPipeline,
	    DanceDiffusionPipeline,
	    DDIMPipeline,
	    DDPMPipeline,
	    DiffusionPipeline,
	    DiTPipeline,
	    ImagePipelineOutput,
	    KarrasVePipeline,
	    LDMPipeline,
	    LDMSuperResolutionPipeline,
	    PNDMPipeline,
	    RePaintPipeline,
	    ScoreSdeVePipeline,
	)
	from .schedulers import (
	    CMStochasticIterativeScheduler,
	    DDIMInverseScheduler,
	    DDIMParallelScheduler,
	    DDIMScheduler,
	    DDPMParallelScheduler,
	    DDPMScheduler,
	    DEISMultistepScheduler,
	    DPMSolverMultistepInverseScheduler,
	    DPMSolverMultistepScheduler,
	    DPMSolverSinglestepScheduler,
	    EulerAncestralDiscreteScheduler,
	    EulerDiscreteScheduler,
	    HeunDiscreteScheduler,
	    IPNDMScheduler,
	    KarrasVeScheduler,
	    KDPMaAncestralDiscreteScheduler,
	    KDPMaDiscreteScheduler,
	    PNDMScheduler,
	    RePaintScheduler,
	    SchedulerMixin,
	    ScoreSdeVeScheduler,
	    UnCLIPScheduler,
	    UniPCMultistepScheduler,
	    VQDiffusionScheduler,
	)
	from .training_utils import EMAModel

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 .schedulers 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 .schedulers import DPMSolverSDEScheduler

try:
	if not (is_torch_available() and is_transformers_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
	from .pipelines import (
	    AltDiffusionImgaImgPipeline,
	    AltDiffusionPipeline,
	    AudioLDMPipeline,
	    CycleDiffusionPipeline,
	    IFImgaImgPipeline,
	    IFImgaImgSuperResolutionPipeline,
	    IFInpaintingPipeline,
	    IFInpaintingSuperResolutionPipeline,
	    IFPipeline,
	    IFSuperResolutionPipeline,
	    ImageTextPipelineOutput,
	    KandinskyImgaImgPipeline,
	    KandinskyInpaintPipeline,
	    KandinskyPipeline,
	    KandinskyPriorPipeline,
	    KandinskyVaaControlnetImgaImgPipeline,
	    KandinskyVaaControlnetPipeline,
	    KandinskyVaaImgaImgPipeline,
	    KandinskyVaaInpaintPipeline,
	    KandinskyVaaPipeline,
	    KandinskyVaaPriorEmbaEmbPipeline,
	    KandinskyVaaPriorPipeline,
	    LDMTextToImagePipeline,
	    PaintByExamplePipeline,
	    SemanticStableDiffusionPipeline,
	    ShapEImgaImgPipeline,
	    ShapEPipeline,
	    StableDiffusionAttendAndExcitePipeline,
	    StableDiffusionControlNetImgaImgPipeline,
	    StableDiffusionControlNetInpaintPipeline,
	    StableDiffusionControlNetPipeline,
	    StableDiffusionDepthaImgPipeline,
	    StableDiffusionDiffEditPipeline,
	    StableDiffusionImageVariationPipeline,
	    StableDiffusionImgaImgPipeline,
	    StableDiffusionInpaintPipeline,
	    StableDiffusionInpaintPipelineLegacy,
	    StableDiffusionInstructPixaPixPipeline,
	    StableDiffusionLatentUpscalePipeline,
	    StableDiffusionLDMaDPipeline,
	    StableDiffusionModelEditingPipeline,
	    StableDiffusionPanoramaPipeline,
	    StableDiffusionParadigmsPipeline,
	    StableDiffusionPipeline,
	    StableDiffusionPipelineSafe,
	    StableDiffusionPixaPixZeroPipeline,
	    StableDiffusionSAGPipeline,
	    StableDiffusionUpscalePipeline,
	    StableUnCLIPImgaImgPipeline,
	    StableUnCLIPPipeline,
	    TextToVideoSDPipeline,
	    TextToVideoZeroPipeline,
	    UnCLIPImageVariationPipeline,
	    UnCLIPPipeline,
	    UniDiffuserModel,
	    UniDiffuserPipeline,
	    UniDiffuserTextDecoder,
	    VersatileDiffusionDualGuidedPipeline,
	    VersatileDiffusionImageVariationPipeline,
	    VersatileDiffusionPipeline,
	    VersatileDiffusionTextToImagePipeline,
	    VideoToVideoSDPipeline,
	    VQDiffusionPipeline,
	)

try:
	if not (is_torch_available() and is_transformers_available() and is_invisible_watermark_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_torch_and_transformers_and_invisible_watermark_objects import *  # noqa F403
else:
	from .pipelines import StableDiffusionXLImgaImgPipeline, StableDiffusionXLPipeline

try:
	if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_torch_and_transformers_and_k_diffusion_objects import *  # noqa F403
else:
	from .pipelines import StableDiffusionKDiffusionPipeline

try:
	if not (is_torch_available() and is_transformers_available() and is_onnx_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_torch_and_transformers_and_onnx_objects import *  # noqa F403
else:
	from .pipelines import (
	    OnnxStableDiffusionImgaImgPipeline,
	    OnnxStableDiffusionInpaintPipeline,
	    OnnxStableDiffusionInpaintPipelineLegacy,
	    OnnxStableDiffusionPipeline,
	    OnnxStableDiffusionUpscalePipeline,
	    StableDiffusionOnnxPipeline,
	)

try:
	if not (is_torch_available() and is_librosa_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_torch_and_librosa_objects import *  # noqa F403
else:
	from .pipelines import AudioDiffusionPipeline, Mel

try:
	if not (is_transformers_available() and is_torch_available() and is_note_seq_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_transformers_and_torch_and_note_seq_objects import *  # noqa F403
else:
	from .pipelines import SpectrogramDiffusionPipeline

try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_flax_objects import *  # noqa F403
else:
	from .models.controlnet_flax import FlaxControlNetModel
	from .models.modeling_flax_utils import FlaxModelMixin
	from .models.unet_ad_condition_flax import FlaxUNetaDConditionModel
	from .models.vae_flax import FlaxAutoencoderKL
	from .pipelines import FlaxDiffusionPipeline
	from .schedulers import (
	    FlaxDDIMScheduler,
	    FlaxDDPMScheduler,
	    FlaxDPMSolverMultistepScheduler,
	    FlaxKarrasVeScheduler,
	    FlaxLMSDiscreteScheduler,
	    FlaxPNDMScheduler,
	    FlaxSchedulerMixin,
	    FlaxScoreSdeVeScheduler,
	)


try:
	if not (is_flax_available() and is_transformers_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_flax_and_transformers_objects import *  # noqa F403
else:
	from .pipelines import (
	    FlaxStableDiffusionControlNetPipeline,
	    FlaxStableDiffusionImgaImgPipeline,
	    FlaxStableDiffusionInpaintPipeline,
	    FlaxStableDiffusionPipeline,
	)

try:
	if not (is_note_seq_available()):
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	from .utils.dummy_note_seq_objects import *  # noqa F403
else:
	from .pipelines import MidiProcessor