



_snake_case						=    '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





"""simple docstring"""

from typing import Dict, List, Optional

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


A_						:    Tuple				=      logging.get_logger(__name__)


A_						:    int				=      {
    'nielsr/canine-s': 2048,
}

# Unicode defines 1,114,112 total “codepoints”
A_						:    List[Any]				=      111_4112

# Below: Constants defining canonical codepoints for special, pseudo-characters.
# Copied from https://github.com/google-research/language/blob/master/language/canine/special_codepoints.py
A_						:    Optional[Any]				=      0

A_						:    int				=      0xE000
A_						:    Any				=      0xE001
A_						:    List[Any]				=      0xE002
A_						:    Optional[Any]				=      0xE003
A_						:    int				=      0xE004

# Maps special codepoints to human-readable names.
A_						:    Dict[int, str]				=      {
    # Special symbols are represented using codepoints values that are valid,
    # but designated as "Private Use", meaning that they will never be assigned
    # characters by the Unicode Consortium, and are thus safe for use here.
    #
    # NOTE: Do *NOT* add any sort of [UNK_CHAR] here. They are explicitly
    # excluded and should fail with a hard error.
    CLS: "[CLS]",
    SEP: "[SEP]",
    BOS: "[BOS]",
    MASK: "[MASK]",
    PAD: "[PAD]",
    RESERVED: "[RESERVED]",
}

# Maps special codepoint human-readable names to their codepoint values.
A_						:    Dict[str, int]				=      {name: codepoint for codepoint, name in SPECIAL_CODEPOINTS.items()}
class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''







	_SCREAMING_SNAKE_CASE	:		List[Any]  						= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES





	def __init__(      self				:       int     ,       _SCREAMING_SNAKE_CASE				:       Any=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       int=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       Union[str, Any]=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       Tuple=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       int=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       Any=chr(_SCREAMING_SNAKE_CASE    )     ,       _SCREAMING_SNAKE_CASE				:       Optional[Any]=False     ,       _SCREAMING_SNAKE_CASE				:       List[Any]=2_048     ,       **_SCREAMING_SNAKE_CASE				:       Tuple     ,       )						->	List[Any]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else bos_token
					SCREAMING_SNAKE_CASE						:							Tuple							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else eos_token
					SCREAMING_SNAKE_CASE						:							Any							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else sep_token
					SCREAMING_SNAKE_CASE						:							int							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else cls_token
					SCREAMING_SNAKE_CASE						:							Dict							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else pad_token

					# Mask token behave like a normal word, i.e. include the space before it
					SCREAMING_SNAKE_CASE						:							int							=     AddedToken(_SCREAMING_SNAKE_CASE     ,       lstrip=_SCREAMING_SNAKE_CASE     ,       rstrip=_SCREAMING_SNAKE_CASE    ) if isinstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    ) else mask_token

					super().__init__(
					    bos_token=_SCREAMING_SNAKE_CASE     ,       eos_token=_SCREAMING_SNAKE_CASE     ,       sep_token=_SCREAMING_SNAKE_CASE     ,       cls_token=_SCREAMING_SNAKE_CASE     ,       pad_token=_SCREAMING_SNAKE_CASE     ,       mask_token=_SCREAMING_SNAKE_CASE     ,       add_prefix_space=_SCREAMING_SNAKE_CASE     ,       model_max_length=_SCREAMING_SNAKE_CASE     ,       **_SCREAMING_SNAKE_CASE     ,       )

					# Creates a mapping for looking up the IDs of special symbols.
					SCREAMING_SNAKE_CASE						:							Dict[str, int]							=     {}
					for codepoint, name in SPECIAL_CODEPOINTS.items():
									SCREAMING_SNAKE_CASE						:							str							=     codepoint

					# Creates a mapping for looking up the string forms of special symbol IDs.
					SCREAMING_SNAKE_CASE						:							Dict[int, str]							=     {
					    codepoint: name for name, codepoint in self._special_codepoints.items()
					}

					SCREAMING_SNAKE_CASE						:							Dict							=     UNICODE_VOCAB_SIZE
					SCREAMING_SNAKE_CASE						:							List[str]							=     len(self._special_codepoints    )





	@property
	def 			_lowerCAmelCase     (      self				:       Optional[Any]    )						->	int:





					"""simple docstring"""


					return self._unicode_vocab_size





	def 			_lowerCAmelCase     (      self				:       Union[str, Any]     ,       _SCREAMING_SNAKE_CASE				:       str    )						->	List[str]:





					"""simple docstring"""


					return list(_SCREAMING_SNAKE_CASE    )





	def 			_lowerCAmelCase     (      self				:       int     ,       _SCREAMING_SNAKE_CASE				:       str    )						->	int:





					"""simple docstring"""


					try:
									return ord(_SCREAMING_SNAKE_CASE    )
					except TypeError:
									raise ValueError(f"""invalid token: '{token}'"""    )





	def 			_lowerCAmelCase     (      self				:       Optional[Any]     ,       _SCREAMING_SNAKE_CASE				:       int    )						->	str:





					"""simple docstring"""


					try:
									if index in SPECIAL_CODEPOINTS:
													return SPECIAL_CODEPOINTS[index]
									return chr(_SCREAMING_SNAKE_CASE    )
					except TypeError:
									raise ValueError(f"""invalid id: {index}"""    )





	def 			_lowerCAmelCase     (      self				:       Optional[Any]     ,       _SCREAMING_SNAKE_CASE				:       Tuple    )						->	List[str]:





					"""simple docstring"""


					return "".join(_SCREAMING_SNAKE_CASE    )





	def 			_lowerCAmelCase     (      self				:       Dict     ,       _SCREAMING_SNAKE_CASE				:       List[int]     ,       _SCREAMING_SNAKE_CASE				:       Optional[List[int]] = None    )						->	List[int]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							List[str]							=     [self.sep_token_id]
					SCREAMING_SNAKE_CASE						:							Tuple							=     [self.cls_token_id]

					SCREAMING_SNAKE_CASE						:							Any							=     cls + token_ids_a + sep
					if token_ids_a is not None:
									result += token_ids_a + sep
					return result





	def 			_lowerCAmelCase     (      self				:       int     ,       _SCREAMING_SNAKE_CASE				:       List[int]     ,       _SCREAMING_SNAKE_CASE				:       Optional[List[int]] = None     ,       _SCREAMING_SNAKE_CASE				:       bool = False    )						->	List[int]:





					"""simple docstring"""


					if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=_SCREAMING_SNAKE_CASE     ,       token_ids_a=_SCREAMING_SNAKE_CASE     ,       already_has_special_tokens=_SCREAMING_SNAKE_CASE    )

					SCREAMING_SNAKE_CASE						:							int							=     [1] + ([0] * len(_SCREAMING_SNAKE_CASE    )) + [1]
					if token_ids_a is not None:
									result += ([0] * len(_SCREAMING_SNAKE_CASE    )) + [1]
					return result





	def 			_lowerCAmelCase     (      self				:       int     ,       _SCREAMING_SNAKE_CASE				:       List[int]     ,       _SCREAMING_SNAKE_CASE				:       Optional[List[int]] = None    )						->	List[int]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     [self.sep_token_id]
					SCREAMING_SNAKE_CASE						:							Dict							=     [self.cls_token_id]

					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     len(cls + token_ids_a + sep    ) * [0]
					if token_ids_a is not None:
									result += len(token_ids_a + sep    ) * [1]
					return result







	def 			_lowerCAmelCase     (      self				:       Tuple     ,       _SCREAMING_SNAKE_CASE				:       str     ,       _SCREAMING_SNAKE_CASE				:       Optional[str] = None    )						->	Any:





					"""simple docstring"""


					return ()





