






"""simple docstring"""
import math

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


lowerCamelCase_       			=   logging.get_logger(__name__)

lowerCamelCase_       			=   {
    '''facebook/data2vec-base-960h''': '''https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json''',
    # See all Data2VecAudio models at https://huggingface.co/models?filter=data2vec-audio
}







class     UpperCamelCase_ (__A  ):
	__magic_name__			   =       '''data2vec-audio'''





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

				# ctc loss
				UpperCAmelCase_  :				str      =      ctc_loss_reduction
				UpperCAmelCase_  :				Tuple      =      ctc_zero_infinity

				# adapter
				UpperCAmelCase_  :				Tuple      =      add_adapter
				UpperCAmelCase_  :				int      =      adapter_kernel_size
				UpperCAmelCase_  :				Optional[int]      =      adapter_stride
				UpperCAmelCase_  :				Union[str, Any]      =      num_adapter_layers
				UpperCAmelCase_  :				Tuple      =      output_hidden_size or hidden_size

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

				# XVector-specific parameters. Feel free to ignore for other classes.
				UpperCAmelCase_  :				str      =      list(lowerCAmelCase_		)
				UpperCAmelCase_  :				List[str]      =      list(lowerCAmelCase_		)
				UpperCAmelCase_  :				Any      =      list(lowerCAmelCase_		)
				UpperCAmelCase_  :				str      =      xvector_output_dim





	@property
	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]		)		->    Optional[Any]:
				return math.prod(self.conv_stride		)











"""simple docstring"""
import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format







class     UpperCamelCase_ :
	__magic_name__			   =       None





	def   _SCREAMING_SNAKE_CASE   (   self      :				Any		)		->    List[Any]:
				UpperCAmelCase_  :				Tuple      =      self.feature_extraction_class(**self.feat_extract_dict		)
				UpperCAmelCase_  :				Union[str, Any]      =      json.loads(feat_extract.to_json_string()		)
				for key, value in self.feat_extract_dict.items():
							self.assertEqual(obj[key]			,			lowerCAmelCase_		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				str		)		->    int:
				UpperCAmelCase_  :				Dict      =      self.feature_extraction_class(**self.feat_extract_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							UpperCAmelCase_  :				List[Any]      =      os.path.join(lowerCAmelCase_			,			"feat_extract.json"		)
							feat_extract_first.to_json_file(lowerCAmelCase_		)
							UpperCAmelCase_  :				Any      =      self.feature_extraction_class.from_json_file(lowerCAmelCase_		)

				self.assertEqual(feat_extract_second.to_dict()			,			feat_extract_first.to_dict()		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				int		)		->    Dict:
				UpperCAmelCase_  :				Optional[Any]      =      self.feature_extraction_class(**self.feat_extract_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							UpperCAmelCase_  :				Optional[Any]      =      feat_extract_first.save_pretrained(lowerCAmelCase_		)[0]
							check_json_file_has_correct_format(lowerCAmelCase_		)
							UpperCAmelCase_  :				Any      =      self.feature_extraction_class.from_pretrained(lowerCAmelCase_		)

				self.assertEqual(feat_extract_second.to_dict()			,			feat_extract_first.to_dict()		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				Any		)		->    Optional[Any]:
				UpperCAmelCase_  :				Optional[int]      =      self.feature_extraction_class()
				self.assertIsNotNone(lowerCAmelCase_		)



