



import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
						pass

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


lowerCamelCase__      =			logging.get_logger(__name__)

lowerCamelCase__      =			{
    'kakaobrain/align-base': 'https://huggingface.co/kakaobrain/align-base/resolve/main/config.json',
}






class  SCREAMING_SNAKE_CASE      (				_lowerCamelCase       ):
							__lowerCamelCase						:						List[Any]     ='''align_text_model'''





							def __init__( self		:		str   ,					__lowercase		:		Any=30522   ,					__lowercase		:		List[Any]=768   ,					__lowercase		:		Tuple=12   ,					__lowercase		:		List[Any]=12   ,					__lowercase		:		List[str]=3072   ,					__lowercase		:		Dict="gelu"   ,					__lowercase		:		Optional[Any]=0.1   ,					__lowercase		:		Tuple=0.1   ,					__lowercase		:		Any=512   ,					__lowercase		:		List[Any]=2   ,					__lowercase		:		int=0.02   ,					__lowercase		:		List[Any]=1E-12   ,					__lowercase		:		Dict=0   ,					__lowercase		:		List[Any]="absolute"   ,					__lowercase		:		Optional[int]=True   ,					**__lowercase		:		Optional[Any]   ,					):

											'''simple docstring'''
											super().__init__(**_SCREAMING_SNAKE_CASE						)

											__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	  =		type_vocab_size
											__a	  =		initializer_range
											__a	  =		layer_norm_eps
											__a	  =		position_embedding_type
											__a	  =		use_cache
											__a	  =		pad_token_id







							@classmethod
							def     UpperCamelCase_       ( cls		:		Any   ,					__lowercase		:		Union[str, os.PathLike]   ,					**__lowercase		:		str						):

											'''simple docstring'''
											cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE						)

											__a	  =		cls.get_config_dict(_SCREAMING_SNAKE_CASE   ,					**_SCREAMING_SNAKE_CASE						)

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






class  SCREAMING_SNAKE_CASE      (				_lowerCamelCase       ):
							__lowerCamelCase						:						Optional[int]     ='''align_vision_model'''





							def __init__( self		:		Dict   ,					__lowercase		:		int = 3   ,					__lowercase		:		int = 600   ,					__lowercase		:		float = 2.0   ,					__lowercase		:		float = 3.1   ,					__lowercase		:		int = 8   ,					__lowercase		:		List[int] = [3, 3, 5, 3, 5, 5, 3]   ,					__lowercase		:		List[int] = [32, 16, 24, 40, 80, 112, 192]   ,					__lowercase		:		List[int] = [16, 24, 40, 80, 112, 192, 320]   ,					__lowercase		:		List[int] = []   ,					__lowercase		:		List[int] = [1, 2, 2, 2, 1, 2, 1]   ,					__lowercase		:		List[int] = [1, 2, 2, 3, 3, 4, 1]   ,					__lowercase		:		List[int] = [1, 6, 6, 6, 6, 6, 6]   ,					__lowercase		:		float = 0.25   ,					__lowercase		:		str = "swish"   ,					__lowercase		:		int = 2560   ,					__lowercase		:		str = "mean"   ,					__lowercase		:		float = 0.02   ,					__lowercase		:		float = 0.001   ,					__lowercase		:		float = 0.99   ,					__lowercase		:		float = 0.2   ,					**__lowercase		:		str   ,					):

											'''simple docstring'''
											super().__init__(**_SCREAMING_SNAKE_CASE						)

											__a	  =		num_channels
											__a	  =		image_size
											__a	  =		width_coefficient
											__a	  =		depth_coefficient
											__a	  =		depth_divisor
											__a	  =		kernel_sizes
											__a	  =		in_channels
											__a	  =		out_channels
											__a	  =		depthwise_padding
											__a	  =		strides
											__a	  =		num_block_repeats
											__a	  =		expand_ratios
											__a	  =		squeeze_expansion_ratio
											__a	  =		hidden_act
											__a	  =		hidden_dim
											__a	  =		pooling_type
											__a	  =		initializer_range
											__a	  =		batch_norm_eps
											__a	  =		batch_norm_momentum
											__a	  =		drop_connect_rate
											__a	  =		sum(_SCREAMING_SNAKE_CASE						) * 4







							@classmethod
							def     UpperCamelCase_       ( cls		:		Dict   ,					__lowercase		:		Union[str, os.PathLike]   ,					**__lowercase		:		Optional[Any]						):

											'''simple docstring'''
											cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE						)

											__a	  =		cls.get_config_dict(_SCREAMING_SNAKE_CASE   ,					**_SCREAMING_SNAKE_CASE						)

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






class  SCREAMING_SNAKE_CASE      (				_lowerCamelCase       ):
							__lowerCamelCase						:						Optional[Any]     ='''align'''
							__lowerCamelCase						:						List[Any]     =True





							def __init__( self		:		List[str]   ,					__lowercase		:		Optional[int]=None   ,					__lowercase		:		List[str]=None   ,					__lowercase		:		Union[str, Any]=640   ,					__lowercase		:		Optional[int]=1.0   ,					__lowercase		:		Optional[int]=0.02   ,					**__lowercase		:		Tuple   ,					):

											'''simple docstring'''
											super().__init__(**_SCREAMING_SNAKE_CASE						)

											if text_config is None:
															__a	  =		{}
															logger.info("""text_config is None. Initializing the AlignTextConfig with default values."""						)

											if vision_config is None:
															__a	  =		{}
															logger.info("""vision_config is None. Initializing the AlignVisionConfig with default values."""						)

											__a	  =		AlignTextConfig(**_SCREAMING_SNAKE_CASE						)
											__a	  =		AlignVisionConfig(**_SCREAMING_SNAKE_CASE						)

											__a	  =		projection_dim
											__a	  =		temperature_init_value
											__a	  =		initializer_range





							@classmethod
							def     UpperCamelCase_       ( cls		:		Dict   ,					__lowercase		:		AlignTextConfig   ,					__lowercase		:		AlignVisionConfig   ,					**__lowercase		:		Optional[Any]						):

											'''simple docstring'''
											return cls(text_config=text_config.to_dict()   ,					vision_config=vision_config.to_dict()   ,					**_SCREAMING_SNAKE_CASE						)







							def     UpperCamelCase_       ( self		:		Optional[Any]						):

											'''simple docstring'''
											__a	  =		copy.deepcopy(self.__dict__						)
											__a	  =		self.text_config.to_dict()
											__a	  =		self.vision_config.to_dict()
											__a	  =		self.__class__.model_type
											return output





"""simple docstring"""

A_						:    Optional[Any]				=      '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





