



"""simple docstring"""

from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxSeqaSeqConfigWithPast
from ...utils import logging


A_						:    Tuple				=      logging.get_logger(__name__)

A_						:    List[Any]				=      {
    't5-small': 'https://huggingface.co/t5-small/resolve/main/config.json',
    't5-base': 'https://huggingface.co/t5-base/resolve/main/config.json',
    't5-large': 'https://huggingface.co/t5-large/resolve/main/config.json',
    't5-3b': 'https://huggingface.co/t5-3b/resolve/main/config.json',
    't5-11b': 'https://huggingface.co/t5-11b/resolve/main/config.json',
}
class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''







	_SCREAMING_SNAKE_CASE	:		Tuple  						= '''t5'''
	_SCREAMING_SNAKE_CASE	:		Optional[Any]  						= ['''past_key_values''']
	_SCREAMING_SNAKE_CASE	:		Optional[int]  						= {'''hidden_size''': '''d_model''', '''num_attention_heads''': '''num_heads''', '''num_hidden_layers''': '''num_layers'''}





	def __init__(      self				:       str     ,       _SCREAMING_SNAKE_CASE				:       Optional[Any]=32_128     ,       _SCREAMING_SNAKE_CASE				:       Optional[int]=512     ,       _SCREAMING_SNAKE_CASE				:       str=64     ,       _SCREAMING_SNAKE_CASE				:       Optional[Any]=2_048     ,       _SCREAMING_SNAKE_CASE				:       Union[str, Any]=6     ,       _SCREAMING_SNAKE_CASE				:       Optional[int]=None     ,       _SCREAMING_SNAKE_CASE				:       List[Any]=8     ,       _SCREAMING_SNAKE_CASE				:       Dict=32     ,       _SCREAMING_SNAKE_CASE				:       List[Any]=128     ,       _SCREAMING_SNAKE_CASE				:       int=0.1     ,       _SCREAMING_SNAKE_CASE				:       List[str]=1E-6     ,       _SCREAMING_SNAKE_CASE				:       Tuple=1.0     ,       _SCREAMING_SNAKE_CASE				:       List[str]="relu"     ,       _SCREAMING_SNAKE_CASE				:       int=True     ,       _SCREAMING_SNAKE_CASE				:       str=True     ,       _SCREAMING_SNAKE_CASE				:       Optional[Any]=0     ,       _SCREAMING_SNAKE_CASE				:       Optional[Any]=1     ,       **_SCREAMING_SNAKE_CASE				:       int     ,       )						->	Any:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     vocab_size
					SCREAMING_SNAKE_CASE						:							List[Any]							=     d_model
					SCREAMING_SNAKE_CASE						:							List[Any]							=     d_kv
					SCREAMING_SNAKE_CASE						:							List[Any]							=     d_ff
					SCREAMING_SNAKE_CASE						:							Dict							=     num_layers
					SCREAMING_SNAKE_CASE						:							List[Any]							=     (
					    num_decoder_layers if num_decoder_layers is not None else self.num_layers
					)  # default = symmetry
					SCREAMING_SNAKE_CASE						:							List[str]							=     num_heads
					SCREAMING_SNAKE_CASE						:							str							=     relative_attention_num_buckets
					SCREAMING_SNAKE_CASE						:							Optional[int]							=     relative_attention_max_distance
					SCREAMING_SNAKE_CASE						:							Tuple							=     dropout_rate
					SCREAMING_SNAKE_CASE						:							str							=     layer_norm_epsilon
					SCREAMING_SNAKE_CASE						:							List[str]							=     initializer_factor
					SCREAMING_SNAKE_CASE						:							List[Any]							=     feed_forward_proj
					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     use_cache

					SCREAMING_SNAKE_CASE						:							List[Any]							=     self.feed_forward_proj.split('-'    )
					SCREAMING_SNAKE_CASE						:							List[Any]							=     act_info[-1]
					SCREAMING_SNAKE_CASE						:							Optional[int]							=     act_info[0] == 'gated'

					if len(_SCREAMING_SNAKE_CASE    ) > 1 and act_info[0] != "gated" or len(_SCREAMING_SNAKE_CASE    ) > 2:
									raise ValueError(
									    f"""`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer."""
									    'Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. '
									    '\'gated-gelu\' or \'relu\''    )

					# for backwards compatibility
					if feed_forward_proj == "gated-gelu":
									SCREAMING_SNAKE_CASE						:							Dict							=     'gelu_new'

					super().__init__(
					    pad_token_id=_SCREAMING_SNAKE_CASE     ,       eos_token_id=_SCREAMING_SNAKE_CASE     ,       is_encoder_decoder=_SCREAMING_SNAKE_CASE     ,       **_SCREAMING_SNAKE_CASE     ,       )




class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''







	@property
	def 			_lowerCAmelCase     (      self				:       List[Any]    )						->	Mapping[str, Mapping[int, str]]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Optional[int]							=     {
					    'input_ids': {0: 'batch', 1: 'encoder_sequence'},
					    'attention_mask': {0: 'batch', 1: 'encoder_sequence'},
					}
					if self.use_past:
									SCREAMING_SNAKE_CASE						:							List[str]							=     'past_encoder_sequence + sequence'
									SCREAMING_SNAKE_CASE						:							List[Any]							=     {0: 'batch'}
									SCREAMING_SNAKE_CASE						:							Optional[int]							=     {0: 'batch', 1: 'past_decoder_sequence + sequence'}
					else:
									SCREAMING_SNAKE_CASE						:							List[str]							=     {0: 'batch', 1: 'decoder_sequence'}
									SCREAMING_SNAKE_CASE						:							Optional[int]							=     {0: 'batch', 1: 'decoder_sequence'}

					if self.use_past:
									self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE     ,       direction='inputs'    )

					return common_inputs







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





					"""simple docstring"""


					return 13










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





