





"""simple docstring"""






import functools
import operator

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


A 			=  logging.get_logger(__name__)

A 			=  {
    '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json''',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}




class 				__lowercase			(			lowercase__							):







					'''simple docstring'''




					__lowerCAmelCase  =  '''wav2vec2'''







					def __init__(						self	,			_UpperCAmelCase=32	,			_UpperCAmelCase=768	,			_UpperCAmelCase=12	,			_UpperCAmelCase=12	,			_UpperCAmelCase=3072	,			_UpperCAmelCase="gelu"	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.0_2	,			_UpperCAmelCase=1e-5	,			_UpperCAmelCase="group"	,			_UpperCAmelCase="gelu"	,			_UpperCAmelCase=(512, 512, 512, 512, 512, 512, 512)	,			_UpperCAmelCase=(5, 2, 2, 2, 2, 2, 2)	,			_UpperCAmelCase=(10, 3, 3, 3, 3, 2, 2)	,			_UpperCAmelCase=False	,			_UpperCAmelCase=128	,			_UpperCAmelCase=16	,			_UpperCAmelCase=False	,			_UpperCAmelCase=True	,			_UpperCAmelCase=0.0_5	,			_UpperCAmelCase=10	,			_UpperCAmelCase=2	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=10	,			_UpperCAmelCase=0	,			_UpperCAmelCase=320	,			_UpperCAmelCase=2	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=100	,			_UpperCAmelCase=256	,			_UpperCAmelCase=256	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase="sum"	,			_UpperCAmelCase=False	,			_UpperCAmelCase=False	,			_UpperCAmelCase=256	,			_UpperCAmelCase=(512, 512, 512, 512, 1500)	,			_UpperCAmelCase=(5, 3, 3, 1, 1)	,			_UpperCAmelCase=(1, 2, 3, 1, 1)	,			_UpperCAmelCase=512	,			_UpperCAmelCase=0	,			_UpperCAmelCase=1	,			_UpperCAmelCase=2	,			_UpperCAmelCase=False	,			_UpperCAmelCase=3	,			_UpperCAmelCase=2	,			_UpperCAmelCase=3	,			_UpperCAmelCase=None	,			_UpperCAmelCase=None	,			**_UpperCAmelCase	,			):
									super().__init__(**UpperCAmelCase__	,			pad_token_id=UpperCAmelCase__	,			bos_token_id=UpperCAmelCase__	,			eos_token_id=UpperCAmelCase__     )
									__a :						Union[str, Any]			       =  hidden_size
									__a :						Optional[int]			       =  feat_extract_norm
									__a :						Optional[int]			       =  feat_extract_activation
									__a :						Dict			       =  list(UpperCAmelCase__     )
									__a :						str			       =  list(UpperCAmelCase__     )
									__a :						str			       =  list(UpperCAmelCase__     )
									__a :						List[Any]			       =  conv_bias
									__a :						List[Any]			       =  num_conv_pos_embeddings
									__a :						Dict			       =  num_conv_pos_embedding_groups
									__a :						Optional[int]			       =  len(self.conv_dim     )
									__a :						Any			       =  num_hidden_layers
									__a :						int			       =  intermediate_size
									__a :						List[str]			       =  hidden_act
									__a :						Dict			       =  num_attention_heads
									__a :						Tuple			       =  hidden_dropout
									__a :						Optional[int]			       =  attention_dropout
									__a :						Tuple			       =  activation_dropout
									__a :						str			       =  feat_proj_dropout
									__a :						int			       =  final_dropout
									__a :						Optional[Any]			       =  layerdrop
									__a :						Union[str, Any]			       =  layer_norm_eps
									__a :						List[str]			       =  initializer_range
									__a :						str			       =  vocab_size
									__a :						Optional[Any]			       =  do_stable_layer_norm
									__a :						List[Any]			       =  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
									__a :						List[Any]			       =  apply_spec_augment
									__a :						Optional[Any]			       =  mask_time_prob
									__a :						Union[str, Any]			       =  mask_time_length
									__a :						Optional[int]			       =  mask_time_min_masks
									__a :						Union[str, Any]			       =  mask_feature_prob
									__a :						Any			       =  mask_feature_length
									__a :						int			       =  mask_feature_min_masks

									# parameters for pretraining with codevector quantized representations
									__a :						Optional[int]			       =  num_codevectors_per_group
									__a :						int			       =  num_codevector_groups
									__a :						Optional[Any]			       =  contrastive_logits_temperature
									__a :						str			       =  feat_quantizer_dropout
									__a :						List[str]			       =  num_negatives
									__a :						int			       =  codevector_dim
									__a :						Any			       =  proj_codevector_dim
									__a :						List[Any]			       =  diversity_loss_weight

									# ctc loss
									__a :						Tuple			       =  ctc_loss_reduction
									__a :						Optional[Any]			       =  ctc_zero_infinity

									# adapter
									__a :						Dict			       =  add_adapter
									__a :						str			       =  adapter_kernel_size
									__a :						Optional[Any]			       =  adapter_stride
									__a :						Union[str, Any]			       =  num_adapter_layers
									__a :						Union[str, Any]			       =  output_hidden_size or hidden_size
									__a :						Dict			       =  adapter_attn_dim

									# SequenceClassification-specific parameter. Feel free to ignore for other classes.
									__a :						Union[str, Any]			       =  classifier_proj_size

									# XVector-specific parameters. Feel free to ignore for other classes.
									__a :						List[str]			       =  list(UpperCAmelCase__     )
									__a :						List[str]			       =  list(UpperCAmelCase__     )
									__a :						Dict			       =  list(UpperCAmelCase__     )
									__a :						Optional[int]			       =  xvector_output_dim







					@property
					def  _lowerCamelCase		(						self     ):
									return functools.reduce(operator.mul	,			self.conv_stride	,			1     )






"""simple docstring"""






import copy
from collections import OrderedDict
from typing import Dict, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


A 			=  logging.get_logger(__name__)

A 			=  {
    '''facebook/detr-resnet-50''': '''https://huggingface.co/facebook/detr-resnet-50/resolve/main/config.json''',
    # See all DETR models at https://huggingface.co/models?filter=detr
}




class 				__lowercase			(			_UpperCamelCase							):







					'''simple docstring'''




					__lowerCAmelCase  =  '''detr'''
					__lowerCAmelCase  =  ['''past_key_values''']
					__lowerCAmelCase  =  {
					    '''hidden_size''': '''d_model''',
					    '''num_attention_heads''': '''encoder_attention_heads''',
					}







					def __init__(						self	,			_UpperCAmelCase=True	,			_UpperCAmelCase=None	,			_UpperCAmelCase=3	,			_UpperCAmelCase=100	,			_UpperCAmelCase=6	,			_UpperCAmelCase=2048	,			_UpperCAmelCase=8	,			_UpperCAmelCase=6	,			_UpperCAmelCase=2048	,			_UpperCAmelCase=8	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=True	,			_UpperCAmelCase="relu"	,			_UpperCAmelCase=256	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.0_2	,			_UpperCAmelCase=1.0	,			_UpperCAmelCase=False	,			_UpperCAmelCase="sine"	,			_UpperCAmelCase="resnet50"	,			_UpperCAmelCase=True	,			_UpperCAmelCase=False	,			_UpperCAmelCase=1	,			_UpperCAmelCase=5	,			_UpperCAmelCase=2	,			_UpperCAmelCase=1	,			_UpperCAmelCase=1	,			_UpperCAmelCase=5	,			_UpperCAmelCase=2	,			_UpperCAmelCase=0.1	,			**_UpperCAmelCase	,			):
									if backbone_config is not None and use_timm_backbone:
													raise ValueError('''You can\'t specify both `backbone_config` and `use_timm_backbone`.'''     )

									if not use_timm_backbone:
													if backbone_config is None:
																	logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''     )
																	__a :						Any			       =  CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']     )
													elif isinstance(_UpperCAmelCase	,			_UpperCAmelCase     ):
																	__a :						Optional[int]			       =  backbone_config.get('''model_type'''     )
																	__a :						Tuple			       =  CONFIG_MAPPING[backbone_model_type]
																	__a :						Union[str, Any]			       =  config_class.from_dict(_UpperCAmelCase     )
													# set timm attributes to None
													__a       ,						__a       ,						__a :						Union[str, Any]			       =  None, None, None

									__a :						Union[str, Any]			       =  use_timm_backbone
									__a :						Any			       =  backbone_config
									__a :						Tuple			       =  num_channels
									__a :						int			       =  num_queries
									__a :						str			       =  d_model
									__a :						Any			       =  encoder_ffn_dim
									__a :						int			       =  encoder_layers
									__a :						Optional[int]			       =  encoder_attention_heads
									__a :						Any			       =  decoder_ffn_dim
									__a :						str			       =  decoder_layers
									__a :						Union[str, Any]			       =  decoder_attention_heads
									__a :						List[Any]			       =  dropout
									__a :						Union[str, Any]			       =  attention_dropout
									__a :						int			       =  activation_dropout
									__a :						Dict			       =  activation_function
									__a :						str			       =  init_std
									__a :						int			       =  init_xavier_std
									__a :						Optional[Any]			       =  encoder_layerdrop
									__a :						Optional[int]			       =  decoder_layerdrop
									__a :						str			       =  encoder_layers
									__a :						List[str]			       =  auxiliary_loss
									__a :						Optional[Any]			       =  position_embedding_type
									__a :						Any			       =  backbone
									__a :						Tuple			       =  use_pretrained_backbone
									__a :						int			       =  dilation
									# Hungarian matcher
									__a :						str			       =  class_cost
									__a :						Optional[Any]			       =  bbox_cost
									__a :						Any			       =  giou_cost
									# Loss coefficients
									__a :						List[str]			       =  mask_loss_coefficient
									__a :						Dict			       =  dice_loss_coefficient
									__a :						str			       =  bbox_loss_coefficient
									__a :						str			       =  giou_loss_coefficient
									__a :						Any			       =  eos_coefficient
									super().__init__(is_encoder_decoder=_UpperCAmelCase	,			**_UpperCAmelCase     )







					@property
					def  _lowerCamelCase		(						self     ):
									return self.encoder_attention_heads







					@property
					def  _lowerCamelCase		(						self     ):
									return self.d_model







					@classmethod
					def  _lowerCamelCase		(						cls	,			_UpperCAmelCase	,			**_UpperCAmelCase     ):
									return cls(backbone_config=_UpperCAmelCase	,			**_UpperCAmelCase     )







					def  _lowerCamelCase		(						self     ):
									__a :						Dict			       =  copy.deepcopy(self.__dict__     )
									if output["backbone_config"] is not None:
													__a :						Tuple			       =  self.backbone_config.to_dict()
									__a :						Dict			       =  self.__class__.model_type
									return output






class 				__lowercase			(			_UpperCamelCase							):







					'''simple docstring'''




					__lowerCAmelCase  =  version.parse('''1.11'''							)







					@property
					def  _lowerCamelCase		(						self     ):
									return OrderedDict(
									    [
									        ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
									        ('''pixel_mask''', {0: '''batch'''}),
									    ]     )







					@property
					def  _lowerCamelCase		(						self     ):
									return 1e-5







					@property
					def  _lowerCamelCase		(						self     ):
									return 12