


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


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

snake_case							:	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 	snake_case_       (lowerCamelCase_				):
					UpperCAmelCase__ :   Dict   				=      '''perceiver'''
					def __init__(				self       :Dict      ,__snake_case       :Dict=2_56      ,__snake_case       :str=12_80      ,__snake_case       :List[str]=7_68      ,__snake_case       :Tuple=1      ,__snake_case       :Optional[Any]=26      ,__snake_case       :Dict=8      ,__snake_case       :Any=8      ,__snake_case       :Optional[int]=None      ,__snake_case       :Tuple=None      ,__snake_case       :Optional[int]="kv"      ,__snake_case       :str=1      ,__snake_case       :Optional[int]=1      ,__snake_case       :Union[str, Any]="gelu"      ,__snake_case       :Tuple=0.1      ,__snake_case       :str=0.02      ,__snake_case       :str=1E-12      ,__snake_case       :List[Any]=True      ,__snake_case       :Any=2_62      ,__snake_case       :Any=20_48      ,__snake_case       :Optional[int]=56      ,__snake_case       :Tuple=[3_68, 4_96]      ,__snake_case       :Tuple=16      ,__snake_case       :int=19_20      ,__snake_case       :Dict=16      ,__snake_case       :int=[1, 16, 2_24, 2_24]      ,**__snake_case       :List[str]      ,) ->   Any:
												super().__init__(**__snake_case				)

												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 	snake_case_       (lowerCamelCase_				):
					@property
					def 			lowerCamelCase__(				self       :int				) ->   Mapping[str, Mapping[int, str]]:
												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 			lowerCamelCase__(				self       :Tuple				) ->   float:
												return 1E-4



					def 			lowerCamelCase__(				self       :Union[str, Any]      ,__snake_case       :Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]      ,__snake_case       :int = -1      ,__snake_case       :int = -1      ,__snake_case       :int = -1      ,__snake_case       :bool = False      ,__snake_case       :Optional[TensorType] = None      ,__snake_case       :int = 3      ,__snake_case       :int = 40      ,__snake_case       :int = 40      ,) ->   Mapping[str, Any]:
												# copied from `transformers.onnx.config.OnnxConfig` and slightly altered/simplified

												if isinstance(__snake_case      ,__snake_case				):
																			# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
																			a__					=					compute_effective_axis_dimension(
																			    __snake_case      ,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(__snake_case				)
																			a__					=					compute_effective_axis_dimension(
																			    __snake_case      ,fixed_dimension=OnnxConfig.default_fixed_sequence      ,num_token_to_add=__snake_case				)
																			# Generate dummy inputs according to compute batch and sequence
																			a__					=					[' '.join(['a']				) * seq_length] * batch_size
																			a__					=					dict(preprocessor(__snake_case      ,return_tensors=__snake_case				)				)
																			a__					=					inputs.pop('input_ids'				)
																			return inputs
												elif isinstance(__snake_case      ,__snake_case				) 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(__snake_case      ,fixed_dimension=OnnxConfig.default_fixed_batch				)
																			a__					=					self._generate_dummy_images(__snake_case      ,__snake_case      ,__snake_case      ,__snake_case				)
																			a__					=					dict(preprocessor(images=__snake_case      ,return_tensors=__snake_case				)				)
																			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.'				)








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


snake_case							:	Optional[int]					      =				logging.get_logger(__name__)

snake_case							:	Union[str, Any]					      =				{
    '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''',
    '''uclanlp/visualbert-vqa-pre''': '''https://huggingface.co/uclanlp/visualbert-vqa-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-vqa-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-vqa-coco-pre/resolve/main/config.json'''
    ),
    '''uclanlp/visualbert-vcr''': '''https://huggingface.co/uclanlp/visualbert-vcr/resolve/main/config.json''',
    '''uclanlp/visualbert-vcr-pre''': '''https://huggingface.co/uclanlp/visualbert-vcr-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-vcr-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-vcr-coco-pre/resolve/main/config.json'''
    ),
    '''uclanlp/visualbert-nlvr2''': '''https://huggingface.co/uclanlp/visualbert-nlvr2/resolve/main/config.json''',
    '''uclanlp/visualbert-nlvr2-pre''': '''https://huggingface.co/uclanlp/visualbert-nlvr2-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-nlvr2-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-nlvr2-coco-pre/resolve/main/config.json'''
    )
    # See all VisualBERT models at https://huggingface.co/models?filter=visual_bert
}







class 	snake_case_       (lowerCamelCase_				):
					UpperCAmelCase__ :   Dict   				=      '''visual_bert'''
					def __init__(				self       :Optional[int]      ,__snake_case       :Any=3_05_22      ,__snake_case       :str=7_68      ,__snake_case       :Any=5_12      ,__snake_case       :Any=12      ,__snake_case       :int=12      ,__snake_case       :str=30_72      ,__snake_case       :int="gelu"      ,__snake_case       :Optional[int]=0.1      ,__snake_case       :str=0.1      ,__snake_case       :Union[str, Any]=5_12      ,__snake_case       :Tuple=2      ,__snake_case       :Union[str, Any]=0.02      ,__snake_case       :Optional[Any]=1E-12      ,__snake_case       :Optional[Any]=False      ,__snake_case       :int=True      ,__snake_case       :Any=1      ,__snake_case       :Optional[int]=0      ,__snake_case       :Tuple=2      ,**__snake_case       :Any      ,) ->   Union[str, Any]:
												super().__init__(pad_token_id=__snake_case      ,bos_token_id=__snake_case      ,eos_token_id=__snake_case      ,**__snake_case				)

												a__					=					vocab_size
												a__					=					max_position_embeddings
												a__					=					hidden_size
												a__					=					visual_embedding_dim
												a__					=					num_hidden_layers
												a__					=					num_attention_heads
												a__					=					intermediate_size
												a__					=					hidden_act
												a__					=					hidden_dropout_prob
												a__					=					attention_probs_dropout_prob
												a__					=					initializer_range
												a__					=					type_vocab_size
												a__					=					layer_norm_eps
												a__					=					bypass_transformer
												a__					=					special_visual_initialize




