






'''simple docstring'''



from collections import OrderedDict
from typing import Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...feature_extraction_utils import FeatureExtractionMixin
from ...onnx import OnnxConfig
from ...onnx.utils import compute_effective_axis_dimension
from ...tokenization_utils_base import PreTrainedTokenizerBase
from ...utils import TensorType, logging


__UpperCamelCase      :       Dict      			=      logging.get_logger(__name__)

__UpperCamelCase      :       List[Any]      			=      {
    """deepmind/language-perceiver""": """https://huggingface.co/deepmind/language-perceiver/resolve/main/config.json""",
    # See all Perceiver models at https://huggingface.co/models?filter=perceiver
}
class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):
						__a  					="perceiver"




						def __init__(  self ,   lowerCamelCase=256 ,   lowerCamelCase=1280 ,   lowerCamelCase=768 ,   lowerCamelCase=1 ,   lowerCamelCase=26 ,   lowerCamelCase=8 ,   lowerCamelCase=8 ,   lowerCamelCase=None ,   lowerCamelCase=None ,   lowerCamelCase="kv" ,   lowerCamelCase=1 ,   lowerCamelCase=1 ,   lowerCamelCase="gelu" ,   lowerCamelCase=0.1 ,   lowerCamelCase=0.02 ,   lowerCamelCase=1e-12 ,   lowerCamelCase=True ,   lowerCamelCase=262 ,   lowerCamelCase=2048 ,   lowerCamelCase=56 ,   lowerCamelCase=[368, 496] ,   lowerCamelCase=16 ,   lowerCamelCase=1920 ,   lowerCamelCase=16 ,   lowerCamelCase=[1, 16, 224, 224] ,   **lowerCamelCase ,   )							->int:



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

									__a				     =    num_latents
									__a				     =    d_latents
									__a				     =    d_model
									__a				     =    num_blocks
									__a				     =    num_self_attends_per_block
									__a				     =    num_self_attention_heads
									__a				     =    num_cross_attention_heads
									__a				     =    qk_channels
									__a				     =    v_channels
									__a				     =    cross_attention_shape_for_attention
									__a				     =    self_attention_widening_factor
									__a				     =    cross_attention_widening_factor
									__a				     =    hidden_act
									__a				     =    attention_probs_dropout_prob
									__a				     =    initializer_range
									__a				     =    layer_norm_eps
									__a				     =    use_query_residual
									# masked language modeling attributes
									__a				     =    vocab_size
									__a				     =    max_position_embeddings
									# image classification attributes
									__a				     =    image_size
									# flow attributes
									__a				     =    train_size
									# multimodal autoencoding attributes
									__a				     =    num_frames
									__a				     =    audio_samples_per_frame
									__a				     =    samples_per_patch
									__a				     =    output_shape







class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):




						@property
						def  __UpperCamelCase							(  self      )							->Mapping[str, Mapping[int, str]]:



									'''simple docstring'''
									if self.task == "multiple-choice":
												__a				     =    {0: 'batch', 1: 'choice', 2: 'sequence'}
									else:
												__a				     =    {0: 'batch', 1: 'sequence'}
									return OrderedDict(
									    [
									        ('inputs', dynamic_axis),
									        ('attention_mask', dynamic_axis),
									    ]      )




						@property
						def  __UpperCamelCase							(  self      )							->float:



									'''simple docstring'''
									return 1e-4






						def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase = -1 ,   lowerCamelCase = -1 ,   lowerCamelCase = -1 ,   lowerCamelCase = False ,   lowerCamelCase = None ,   lowerCamelCase = 3 ,   lowerCamelCase = 40 ,   lowerCamelCase = 40 ,   )							->Mapping[str, Any]:



									'''simple docstring'''
									# copied from `transformers.onnx.config.OnnxConfig` and slightly altered/simplified

									if isinstance(__a ,   __a      ):
												# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
												__a				     =    compute_effective_axis_dimension(
												    __a ,   fixed_dimension=OnnxConfig.default_fixed_batch ,   num_token_to_add=0      )
												# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
												__a				     =    preprocessor.num_special_tokens_to_add(__a      )
												__a				     =    compute_effective_axis_dimension(
												    __a ,   fixed_dimension=OnnxConfig.default_fixed_sequence ,   num_token_to_add=__a      )
												# Generate dummy inputs according to compute batch and sequence
												__a				     =    [' '.join(['a']      ) * seq_length] * batch_size
												__a				     =    dict(preprocessor(__a ,   return_tensors=__a      )      )
												__a				     =    inputs.pop('input_ids'      )
												return inputs
									elif isinstance(__a ,   __a      ) and preprocessor.model_input_names[0] == "pixel_values":
												# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
												__a				     =    compute_effective_axis_dimension(__a ,   fixed_dimension=OnnxConfig.default_fixed_batch      )
												__a				     =    self._generate_dummy_images(__a ,   __a ,   __a ,   __a      )
												__a				     =    dict(preprocessor(images=__a ,   return_tensors=__a      )      )
												__a				     =    inputs.pop('pixel_values'      )
												return inputs
									else:
												raise ValueError(
												    'Unable to generate dummy inputs for the model. Please provide a tokenizer or a preprocessor.'      )







'''simple docstring'''



__UpperCamelCase      :       Tuple      			=      """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