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


__lowercase							:   List[str]					=     logging.get_logger(__name__)

__lowercase							:   Tuple					=     {
    """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 	__lowercase				(  __snake_case    ):
			lowerCamelCase			:		int	      =			'perceiver'

			def __init__(self			,   A=2_5_6			,   A=1_2_8_0			,   A=7_6_8			,   A=1			,   A=2_6			,   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=2_6_2			,   A=2_0_4_8			,   A=5_6			,   A=[3_6_8, 4_9_6]			,   A=1_6			,   A=1_9_2_0			,   A=1_6			,   A=[1, 1_6, 2_2_4, 2_2_4]			,   **A			,   ):
								super().__init__(**A_      )

								lowerCamelCase_					:      List[Any]     =		num_latents
								lowerCamelCase_					:      int     =		d_latents
								lowerCamelCase_					:      List[Any]     =		d_model
								lowerCamelCase_					:      Union[str, Any]     =		num_blocks
								lowerCamelCase_					:      List[Any]     =		num_self_attends_per_block
								lowerCamelCase_					:      List[str]     =		num_self_attention_heads
								lowerCamelCase_					:      str     =		num_cross_attention_heads
								lowerCamelCase_					:      Optional[Any]     =		qk_channels
								lowerCamelCase_					:      List[Any]     =		v_channels
								lowerCamelCase_					:      Tuple     =		cross_attention_shape_for_attention
								lowerCamelCase_					:      Optional[int]     =		self_attention_widening_factor
								lowerCamelCase_					:      List[str]     =		cross_attention_widening_factor
								lowerCamelCase_					:      List[str]     =		hidden_act
								lowerCamelCase_					:      List[str]     =		attention_probs_dropout_prob
								lowerCamelCase_					:      Optional[int]     =		initializer_range
								lowerCamelCase_					:      Any     =		layer_norm_eps
								lowerCamelCase_					:      Optional[Any]     =		use_query_residual
								# masked language modeling attributes
								lowerCamelCase_					:      Optional[int]     =		vocab_size
								lowerCamelCase_					:      Optional[int]     =		max_position_embeddings
								# image classification attributes
								lowerCamelCase_					:      Dict     =		image_size
								# flow attributes
								lowerCamelCase_					:      str     =		train_size
								# multimodal autoencoding attributes
								lowerCamelCase_					:      Optional[int]     =		num_frames
								lowerCamelCase_					:      List[Any]     =		audio_samples_per_frame
								lowerCamelCase_					:      int     =		samples_per_patch
								lowerCamelCase_					:      str     =		output_shape

class 	__lowercase				(  __snake_case    ):

			@property
			def        UpperCAmelCase__ (self      ):




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

			@property
			def        UpperCAmelCase__ (self      ):
								return 1E-4






			def        UpperCAmelCase__ (self			,   A			,   A = -1			,   A = -1			,   A = -1			,   A = False			,   A = None			,   A = 3			,   A = 4_0			,   A = 4_0			,   ):




								if isinstance(A_			,   A_      ):
													# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
													lowerCamelCase_					:      Union[str, Any]     =		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
													lowerCamelCase_					:      Optional[int]     =		preprocessor.num_special_tokens_to_add(A_      )
													lowerCamelCase_					:      List[Any]     =		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
													lowerCamelCase_					:      str     =		[" ".join(['''a''']      ) * seq_length] * batch_size
													lowerCamelCase_					:      Tuple     =		dict(preprocessor(A_			,   return_tensors=A_      )      )
													lowerCamelCase_					:      int     =		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
													lowerCamelCase_					:      List[str]     =		compute_effective_axis_dimension(A_			,   fixed_dimension=OnnxConfig.default_fixed_batch      )
													lowerCamelCase_					:      List[Any]     =		self._generate_dummy_images(A_			,   A_			,   A_			,   A_      )
													lowerCamelCase_					:      Tuple     =		dict(preprocessor(images=A_			,   return_tensors=A_      )      )
													lowerCamelCase_					:      Any     =		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'''


from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowercase							:   str					=     {
    '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''],
    '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''],
    '''processing_mctct''': ['''MCTCTProcessor'''],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowercase							:   str					=     [
					    '''MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''MCTCTForCTC''',
					    '''MCTCTModel''',
					    '''MCTCTPreTrainedModel''',
					]


if TYPE_CHECKING:
					from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
					from .feature_extraction_mctct import MCTCTFeatureExtractor
					from .processing_mctct import MCTCTProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
					import sys

					__lowercase							:   Union[str, Any]					=     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


