
'''simple docstring'''
import functools
import operator

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


lowerCAmelCase					:    int           = logging.get_logger(__name__)

lowerCAmelCase					:    Tuple           = {
    'microsoft/unispeech-sat-base-100h-libri-ft': (
        'https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json'
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}


class 			SCREAMING_SNAKE_CASE__      (     snake_case_):
				lowerCAmelCase_     			=							"""unispeech-sat"""







				def __init__(       self						,				A_=32						,				A_=768						,				A_=12						,				A_=12						,				A_=3072						,				A_="gelu"						,				A_=0.1						,				A_=0.1						,				A_=0.1						,				A_=0.0						,				A_=0.0						,				A_=0.1						,				A_=0.1						,				A_=0.02						,				A_=1e-5						,				A_="group"						,				A_="gelu"						,				A_=(512, 512, 512, 512, 512, 512, 512)						,				A_=(5, 2, 2, 2, 2, 2, 2)						,				A_=(10, 3, 3, 3, 3, 2, 2)						,				A_=False						,				A_=128						,				A_=16						,				A_=False						,				A_=True						,				A_=0.05						,				A_=10						,				A_=2						,				A_=0.0						,				A_=10						,				A_=0						,				A_=320						,				A_=2						,				A_=0.1						,				A_=100						,				A_=256						,				A_=256						,				A_=0.1						,				A_="mean"						,				A_=False						,				A_=False						,				A_=256						,				A_=(512, 512, 512, 512, 1500)						,				A_=(5, 3, 3, 1, 1)						,				A_=(1, 2, 3, 1, 1)						,				A_=512						,				A_=0						,				A_=1						,				A_=2						,				A_=504						,				**A_						,				)->		Tuple:







											'''simple docstring'''






											super().__init__(**A_						,				pad_token_id=A_						,				bos_token_id=A_						,				eos_token_id=A_     )
											UpperCamelCase   			=     hidden_size
											UpperCamelCase   			=     feat_extract_norm
											UpperCamelCase   			=     feat_extract_activation
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     conv_bias
											UpperCamelCase   			=     num_conv_pos_embeddings
											UpperCamelCase   			=     num_conv_pos_embedding_groups
											UpperCamelCase   			=     len(self.conv_dim     )
											UpperCamelCase   			=     num_hidden_layers
											UpperCamelCase   			=     intermediate_size
											UpperCamelCase   			=     hidden_act
											UpperCamelCase   			=     num_attention_heads
											UpperCamelCase   			=     hidden_dropout
											UpperCamelCase   			=     attention_dropout
											UpperCamelCase   			=     activation_dropout
											UpperCamelCase   			=     feat_proj_dropout
											UpperCamelCase   			=     final_dropout
											UpperCamelCase   			=     layerdrop
											UpperCamelCase   			=     layer_norm_eps
											UpperCamelCase   			=     initializer_range
											UpperCamelCase   			=     vocab_size
											UpperCamelCase   			=     num_clusters
											UpperCamelCase   			=     do_stable_layer_norm
											UpperCamelCase   			=     use_weighted_layer_sum

											if (
											    (len(self.conv_stride     ) != self.num_feat_extract_layers)
											    or (len(self.conv_kernel     ) != self.num_feat_extract_layers)
											    or (len(self.conv_dim     ) != self.num_feat_extract_layers)
											):
																		raise ValueError(
																		    'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
																		    ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
																		    F''' {len(self.conv_dim     )}`, `len(config.conv_stride) = {len(self.conv_stride     )}`,'''
																		    F''' `len(config.conv_kernel) = {len(self.conv_kernel     )}`.'''     )

											# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
											UpperCamelCase   			=     apply_spec_augment
											UpperCamelCase   			=     mask_time_prob
											UpperCamelCase   			=     mask_time_length
											UpperCamelCase   			=     mask_time_min_masks
											UpperCamelCase   			=     mask_feature_prob
											UpperCamelCase   			=     mask_feature_length
											UpperCamelCase   			=     mask_feature_min_masks

											# parameters for pretraining with codevector quantized representations
											UpperCamelCase   			=     num_codevectors_per_group
											UpperCamelCase   			=     num_codevector_groups
											UpperCamelCase   			=     contrastive_logits_temperature
											UpperCamelCase   			=     feat_quantizer_dropout
											UpperCamelCase   			=     num_negatives
											UpperCamelCase   			=     codevector_dim
											UpperCamelCase   			=     proj_codevector_dim
											UpperCamelCase   			=     diversity_loss_weight

											# ctc loss
											UpperCamelCase   			=     ctc_loss_reduction
											UpperCamelCase   			=     ctc_zero_infinity

											# SequenceClassification-specific parameter. Feel free to ignore for other classes.
											UpperCamelCase   			=     classifier_proj_size

											# XVector-specific parameters. Feel free to ignore for other classes.
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     list(A_     )
											UpperCamelCase   			=     xvector_output_dim







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







											'''simple docstring'''






											return functools.reduce(operator.mul						,				self.conv_stride						,				1     )






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


lowerCAmelCase					:    Any           = logging.get_logger(__name__)

lowerCAmelCase					:    Optional[int]           = {
    '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__      (     snake_case_):
				lowerCAmelCase_     			=							"""perceiver"""







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







											'''simple docstring'''






											super().__init__(**A_     )

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


class 			SCREAMING_SNAKE_CASE__      (     snake_case_):







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







											'''simple docstring'''






											if self.task == "multiple-choice":
																		UpperCamelCase   			=     {0: 'batch', 1: 'choice', 2: 'sequence'}
											else:
																		UpperCamelCase   			=     {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						,				A_						,				A_ = -1						,				A_ = -1						,				A_ = -1						,				A_ = False						,				A_ = None						,				A_ = 3						,				A_ = 40						,				A_ = 40						,				)->		Mapping[str, Any]:







											'''simple docstring'''






											if isinstance(A_						,				A_     ):
																		# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
																		UpperCamelCase   			=     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
																		UpperCamelCase   			=     preprocessor.num_special_tokens_to_add(A_     )
																		UpperCamelCase   			=     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
																		UpperCamelCase   			=     [' '.join(['a']     ) * seq_length] * batch_size
																		UpperCamelCase   			=     dict(preprocessor(A_						,				return_tensors=A_     )     )
																		UpperCamelCase   			=     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
																		UpperCamelCase   			=     compute_effective_axis_dimension(A_						,				fixed_dimension=OnnxConfig.default_fixed_batch     )
																		UpperCamelCase   			=     self._generate_dummy_images(A_						,				A_						,				A_						,				A_     )
																		UpperCamelCase   			=     dict(preprocessor(images=A_						,				return_tensors=A_     )     )
																		UpperCamelCase   			=     inputs.pop('pixel_values'     )
																		return inputs
											else:
																		raise ValueError(
																		    'Unable to generate dummy inputs for the model. Please provide a tokenizer or a preprocessor.'     )




