'''simple docstring'''







import copy
import os
from typing import Union

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


UpperCamelCase_      	=	logging.get_logger(__name__)

UpperCamelCase_      	=	{
    '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/resolve/main/config.json''',
}




class _SCREAMING_SNAKE_CASE(							_SCREAMING_SNAKE_CASE					):
						A_			:							List[Any]     		= 'git_vision_model'




						def __init__(    self :       List[str]							,							UpperCamelCase_ :       Optional[Any]=7_68							,							UpperCamelCase_ :       Optional[Any]=30_72							,							UpperCamelCase_ :       List[Any]=12							,							UpperCamelCase_ :       Tuple=12							,							UpperCamelCase_ :       Optional[Any]=3							,							UpperCamelCase_ :       Dict=2_24							,							UpperCamelCase_ :       Union[str, Any]=16							,							UpperCamelCase_ :       List[Any]="quick_gelu"							,							UpperCamelCase_ :       Optional[int]=1e-5							,							UpperCamelCase_ :       Union[str, Any]=0.0							,							UpperCamelCase_ :       Any=0.02							,							**UpperCamelCase_ :       Optional[int]							,							)     ->				int:
													super().__init__(**SCREAMING_SNAKE_CASE_      )

													SCREAMING_SNAKE_CASE__     :str						    = hidden_size
													SCREAMING_SNAKE_CASE__     :List[Any]						    = intermediate_size
													SCREAMING_SNAKE_CASE__     :Any						    = num_hidden_layers
													SCREAMING_SNAKE_CASE__     :List[Any]						    = num_attention_heads
													SCREAMING_SNAKE_CASE__     :Union[str, Any]						    = num_channels
													SCREAMING_SNAKE_CASE__     :List[Any]						    = patch_size
													SCREAMING_SNAKE_CASE__     :Optional[int]						    = image_size
													SCREAMING_SNAKE_CASE__     :Union[str, Any]						    = initializer_range
													SCREAMING_SNAKE_CASE__     :Tuple						    = attention_dropout
													SCREAMING_SNAKE_CASE__     :List[str]						    = layer_norm_eps
													SCREAMING_SNAKE_CASE__     :Optional[Any]						    = hidden_act




						@classmethod
						def      __lowerCamelCase       (    cls :       Any							,							UpperCamelCase_ :       Union[str, os.PathLike]							,							**UpperCamelCase_ :       str      )     ->				"PretrainedConfig":
													cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE_      )

													SCREAMING_SNAKE_CASE__    ,      SCREAMING_SNAKE_CASE__     :int						    = cls.get_config_dict(SCREAMING_SNAKE_CASE_							,							**SCREAMING_SNAKE_CASE_      )

													# get the vision config dict if we are loading from GITConfig
													if config_dict.get('model_type'      ) == "git":
																				SCREAMING_SNAKE_CASE__     :List[Any]						    = config_dict['vision_config']

													if "model_type" in config_dict and hasattr(cls							,							'model_type'      ) and config_dict["model_type"] != cls.model_type:
																				logger.warning(
																				    f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
																				    f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''      )

													return cls.from_dict(SCREAMING_SNAKE_CASE_							,							**SCREAMING_SNAKE_CASE_      )




class _SCREAMING_SNAKE_CASE(							_SCREAMING_SNAKE_CASE					):
						A_			:							int     		= 'git'




						def __init__(    self :       Union[str, Any]							,							UpperCamelCase_ :       Optional[int]=None							,							UpperCamelCase_ :       Union[str, Any]=3_05_22							,							UpperCamelCase_ :       Union[str, Any]=7_68							,							UpperCamelCase_ :       Tuple=6							,							UpperCamelCase_ :       Union[str, Any]=12							,							UpperCamelCase_ :       List[Any]=30_72							,							UpperCamelCase_ :       Optional[Any]="gelu"							,							UpperCamelCase_ :       str=0.1							,							UpperCamelCase_ :       int=0.1							,							UpperCamelCase_ :       str=10_24							,							UpperCamelCase_ :       List[str]=0.02							,							UpperCamelCase_ :       List[Any]=1e-12							,							UpperCamelCase_ :       Dict=0							,							UpperCamelCase_ :       Optional[Any]="absolute"							,							UpperCamelCase_ :       Any=True							,							UpperCamelCase_ :       Tuple=False							,							UpperCamelCase_ :       Union[str, Any]=1_01							,							UpperCamelCase_ :       Optional[int]=1_02							,							UpperCamelCase_ :       Any=None							,							**UpperCamelCase_ :       Union[str, Any]							,							)     ->				str:
													super().__init__(bos_token_id=SCREAMING_SNAKE_CASE_							,							eos_token_id=SCREAMING_SNAKE_CASE_							,							pad_token_id=SCREAMING_SNAKE_CASE_							,							**SCREAMING_SNAKE_CASE_      )

													if vision_config is None:
																				SCREAMING_SNAKE_CASE__     :List[Any]						    = {}
																				logger.info('vision_config is None. initializing the GitVisionConfig with default values.'      )

													SCREAMING_SNAKE_CASE__     :List[Any]						    = GitVisionConfig(**SCREAMING_SNAKE_CASE_      )
													SCREAMING_SNAKE_CASE__     :Any						    = vocab_size
													SCREAMING_SNAKE_CASE__     :List[str]						    = hidden_size
													SCREAMING_SNAKE_CASE__     :List[Any]						    = num_hidden_layers
													SCREAMING_SNAKE_CASE__     :List[str]						    = num_attention_heads
													SCREAMING_SNAKE_CASE__     :List[Any]						    = hidden_act
													SCREAMING_SNAKE_CASE__     :Tuple						    = intermediate_size
													SCREAMING_SNAKE_CASE__     :Optional[Any]						    = hidden_dropout_prob
													SCREAMING_SNAKE_CASE__     :int						    = attention_probs_dropout_prob
													SCREAMING_SNAKE_CASE__     :int						    = max_position_embeddings
													SCREAMING_SNAKE_CASE__     :Union[str, Any]						    = initializer_range
													SCREAMING_SNAKE_CASE__     :int						    = layer_norm_eps
													SCREAMING_SNAKE_CASE__     :Any						    = position_embedding_type
													SCREAMING_SNAKE_CASE__     :Union[str, Any]						    = use_cache
													SCREAMING_SNAKE_CASE__     :Union[str, Any]						    = tie_word_embeddings
													SCREAMING_SNAKE_CASE__     :Optional[Any]						    = num_image_with_embedding

													SCREAMING_SNAKE_CASE__     :List[Any]						    = bos_token_id
													SCREAMING_SNAKE_CASE__     :List[str]						    = eos_token_id




						def      __lowerCamelCase       (    self :       Dict      )     ->				List[Any]:
													SCREAMING_SNAKE_CASE__     :Any						    = copy.deepcopy(self.__dict__      )
													SCREAMING_SNAKE_CASE__     :Any						    = self.vision_config.to_dict()
													SCREAMING_SNAKE_CASE__     :Any						    = self.__class__.model_type
													return output








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__(							UpperCAmelCase				):



	"""simple docstring"""




	a     :Optional[int]       	=      'wav2vec2'
	def __init__(			self    :     Optional[Any]			,				SCREAMING_SNAKE_CASE_    :     List[str]=3_2			,				SCREAMING_SNAKE_CASE_    :     Optional[Any]=7_6_8			,				SCREAMING_SNAKE_CASE_    :     int=1_2			,				SCREAMING_SNAKE_CASE_    :     Any=1_2			,				SCREAMING_SNAKE_CASE_    :     Optional[int]=3_0_7_2			,				SCREAMING_SNAKE_CASE_    :     Dict="gelu"			,				SCREAMING_SNAKE_CASE_    :     Optional[int]=0.1			,				SCREAMING_SNAKE_CASE_    :     str=0.1			,				SCREAMING_SNAKE_CASE_    :     List[Any]=0.1			,				SCREAMING_SNAKE_CASE_    :     Union[str, Any]=0.0			,				SCREAMING_SNAKE_CASE_    :     Optional[int]=0.0			,				SCREAMING_SNAKE_CASE_    :     Any=0.1			,				SCREAMING_SNAKE_CASE_    :     str=0.1			,				SCREAMING_SNAKE_CASE_    :     Any=0.02			,				SCREAMING_SNAKE_CASE_    :     Dict=1e-5			,				SCREAMING_SNAKE_CASE_    :     List[Any]="group"			,				SCREAMING_SNAKE_CASE_    :     List[str]="gelu"			,				SCREAMING_SNAKE_CASE_    :     List[Any]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)			,				SCREAMING_SNAKE_CASE_    :     Any=(5, 2, 2, 2, 2, 2, 2)			,				SCREAMING_SNAKE_CASE_    :     Union[str, Any]=(1_0, 3, 3, 3, 3, 2, 2)			,				SCREAMING_SNAKE_CASE_    :     List[str]=False			,				SCREAMING_SNAKE_CASE_    :     Optional[int]=1_2_8			,				SCREAMING_SNAKE_CASE_    :     str=1_6			,				SCREAMING_SNAKE_CASE_    :     Any=False			,				SCREAMING_SNAKE_CASE_    :     int=True			,				SCREAMING_SNAKE_CASE_    :     str=0.05			,				SCREAMING_SNAKE_CASE_    :     Dict=1_0			,				SCREAMING_SNAKE_CASE_    :     Tuple=2			,				SCREAMING_SNAKE_CASE_    :     List[str]=0.0			,				SCREAMING_SNAKE_CASE_    :     List[str]=1_0			,				SCREAMING_SNAKE_CASE_    :     List[Any]=0			,				SCREAMING_SNAKE_CASE_    :     Dict=3_2_0			,				SCREAMING_SNAKE_CASE_    :     Any=2			,				SCREAMING_SNAKE_CASE_    :     Tuple=0.1			,				SCREAMING_SNAKE_CASE_    :     Optional[Any]=1_0_0			,				SCREAMING_SNAKE_CASE_    :     List[Any]=2_5_6			,				SCREAMING_SNAKE_CASE_    :     int=2_5_6			,				SCREAMING_SNAKE_CASE_    :     str=0.1			,				SCREAMING_SNAKE_CASE_    :     List[str]="sum"			,				SCREAMING_SNAKE_CASE_    :     Tuple=False			,				SCREAMING_SNAKE_CASE_    :     Union[str, Any]=False			,				SCREAMING_SNAKE_CASE_    :     Optional[int]=2_5_6			,				SCREAMING_SNAKE_CASE_    :     Optional[Any]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)			,				SCREAMING_SNAKE_CASE_    :     List[Any]=(5, 3, 3, 1, 1)			,				SCREAMING_SNAKE_CASE_    :     List[Any]=(1, 2, 3, 1, 1)			,				SCREAMING_SNAKE_CASE_    :     Tuple=5_1_2			,				SCREAMING_SNAKE_CASE_    :     Dict=0			,				SCREAMING_SNAKE_CASE_    :     Union[str, Any]=1			,				SCREAMING_SNAKE_CASE_    :     int=2			,				SCREAMING_SNAKE_CASE_    :     Dict=False			,				SCREAMING_SNAKE_CASE_    :     int=3			,				SCREAMING_SNAKE_CASE_    :     List[Any]=2			,				SCREAMING_SNAKE_CASE_    :     str=3			,				SCREAMING_SNAKE_CASE_    :     Any=None			,				SCREAMING_SNAKE_CASE_    :     int=None			,				**SCREAMING_SNAKE_CASE_    :     Optional[Any]			,				)			->	Any:
					super().__init__(**SCREAMING_SNAKE_CASE_			,				pad_token_id=SCREAMING_SNAKE_CASE_			,				bos_token_id=SCREAMING_SNAKE_CASE_			,				eos_token_id=SCREAMING_SNAKE_CASE_			)
					lowercase_	    =   hidden_size
					lowercase_	    =   feat_extract_norm
					lowercase_	    =   feat_extract_activation
					lowercase_	    =   list(SCREAMING_SNAKE_CASE_			)
					lowercase_	    =   list(SCREAMING_SNAKE_CASE_			)
					lowercase_	    =   list(SCREAMING_SNAKE_CASE_			)
					lowercase_	    =   conv_bias
					lowercase_	    =   num_conv_pos_embeddings
					lowercase_	    =   num_conv_pos_embedding_groups
					lowercase_	    =   len(self.conv_dim			)
					lowercase_	    =   num_hidden_layers
					lowercase_	    =   intermediate_size
					lowercase_	    =   hidden_act
					lowercase_	    =   num_attention_heads
					lowercase_	    =   hidden_dropout
					lowercase_	    =   attention_dropout
					lowercase_	    =   activation_dropout
					lowercase_	    =   feat_proj_dropout
					lowercase_	    =   final_dropout
					lowercase_	    =   layerdrop
					lowercase_	    =   layer_norm_eps
					lowercase_	    =   initializer_range
					lowercase_	    =   vocab_size
					lowercase_	    =   do_stable_layer_norm
					lowercase_	    =   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
					lowercase_	    =   apply_spec_augment
					lowercase_	    =   mask_time_prob
					lowercase_	    =   mask_time_length
					lowercase_	    =   mask_time_min_masks
					lowercase_	    =   mask_feature_prob
					lowercase_	    =   mask_feature_length
					lowercase_	    =   mask_feature_min_masks

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

					# ctc loss
					lowercase_	    =   ctc_loss_reduction
					lowercase_	    =   ctc_zero_infinity

					# adapter
					lowercase_	    =   add_adapter
					lowercase_	    =   adapter_kernel_size
					lowercase_	    =   adapter_stride
					lowercase_	    =   num_adapter_layers
					lowercase_	    =   output_hidden_size or hidden_size
					lowercase_	    =   adapter_attn_dim

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

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




	@property
	def 		_lowercase    (			self    :     Any			)			->	Dict:
					return functools.reduce(operator.mul			,				self.conv_stride			,				1			)




