

"""simple docstring"""


import math

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


__A						       =      logging.get_logger(__name__)

__A						       =      {
    "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    snake_case     (    __snake_case  ):
				SCREAMING_SNAKE_CASE_       :				List[Any]       				=  """data2vec-audio"""

				def __init__(     self							:    Any					,  UpperCamelCase__							:    Tuple=3_2					,  UpperCamelCase__							:    Dict=7_6_8					,  UpperCamelCase__							:    Union[str, Any]=1_2					,  UpperCamelCase__							:    Any=1_2					,  UpperCamelCase__							:    str=3_0_7_2					,  UpperCamelCase__							:    Union[str, Any]="gelu"					,  UpperCamelCase__							:    List[Any]=0.1					,  UpperCamelCase__							:    Tuple=0.1					,  UpperCamelCase__							:    List[str]=0.1					,  UpperCamelCase__							:    Tuple=0.0					,  UpperCamelCase__							:    Any=0.1					,  UpperCamelCase__							:    int=0.1					,  UpperCamelCase__							:    Dict=0.02					,  UpperCamelCase__							:    Any=1e-5					,  UpperCamelCase__							:    List[str]="gelu"					,  UpperCamelCase__							:    List[str]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)					,  UpperCamelCase__							:    str=(5, 2, 2, 2, 2, 2, 2)					,  UpperCamelCase__							:    Union[str, Any]=(1_0, 3, 3, 3, 3, 2, 2)					,  UpperCamelCase__							:    str=False					,  UpperCamelCase__							:    Union[str, Any]=1_6					,  UpperCamelCase__							:    Optional[int]=1_9					,  UpperCamelCase__							:    Dict=5					,  UpperCamelCase__							:    List[Any]=0.05					,  UpperCamelCase__							:    int=1_0					,  UpperCamelCase__							:    Optional[Any]=2					,  UpperCamelCase__							:    Dict=0.0					,  UpperCamelCase__							:    Optional[Any]=1_0					,  UpperCamelCase__							:    Dict=0					,  UpperCamelCase__							:    int="sum"					,  UpperCamelCase__							:    Dict=False					,  UpperCamelCase__							:    Any=False					,  UpperCamelCase__							:    Optional[int]=2_5_6					,  UpperCamelCase__							:    Any=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)					,  UpperCamelCase__							:    List[Any]=(5, 3, 3, 1, 1)					,  UpperCamelCase__							:    List[str]=(1, 2, 3, 1, 1)					,  UpperCamelCase__							:    Tuple=5_1_2					,  UpperCamelCase__							:    int=0					,  UpperCamelCase__							:    List[str]=1					,  UpperCamelCase__							:    Optional[int]=2					,  UpperCamelCase__							:    Optional[Any]=False					,  UpperCamelCase__							:    Dict=3					,  UpperCamelCase__							:    Optional[Any]=2					,  UpperCamelCase__							:    Union[str, Any]=3					,  UpperCamelCase__							:    int=None					,  **UpperCamelCase__							:    List[Any]					,  )->       Dict:



						'''simple docstring'''


						super().__init__(**UpperCamelCase__					,  pad_token_id=UpperCamelCase__					,  bos_token_id=UpperCamelCase__					,  eos_token_id=UpperCamelCase__)
						__lowerCAmelCase:	str   				=      hidden_size
						__lowerCAmelCase:	Union[str, Any]   				=      feat_extract_activation
						__lowerCAmelCase:	Any   				=      list(UpperCamelCase__)
						__lowerCAmelCase:	List[str]   				=      list(UpperCamelCase__)
						__lowerCAmelCase:	Optional[int]   				=      list(UpperCamelCase__)
						__lowerCAmelCase:	Dict   				=      conv_bias
						__lowerCAmelCase:	str   				=      num_conv_pos_embeddings
						__lowerCAmelCase:	Dict   				=      num_conv_pos_embedding_groups
						__lowerCAmelCase:	int   				=      conv_pos_kernel_size
						__lowerCAmelCase:	Dict   				=      len(self.conv_dim)
						__lowerCAmelCase:	Dict   				=      num_hidden_layers
						__lowerCAmelCase:	Dict   				=      intermediate_size
						__lowerCAmelCase:	int   				=      hidden_act
						__lowerCAmelCase:	Any   				=      num_attention_heads
						__lowerCAmelCase:	List[Any]   				=      hidden_dropout
						__lowerCAmelCase:	Optional[Any]   				=      attention_dropout
						__lowerCAmelCase:	Optional[Any]   				=      activation_dropout
						__lowerCAmelCase:	Optional[Any]   				=      feat_proj_dropout
						__lowerCAmelCase:	Any   				=      final_dropout
						__lowerCAmelCase:	Optional[int]   				=      layerdrop
						__lowerCAmelCase:	Optional[Any]   				=      layer_norm_eps
						__lowerCAmelCase:	Dict   				=      initializer_range
						__lowerCAmelCase:	Any   				=      vocab_size
						__lowerCAmelCase:	Optional[int]   				=      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
						__lowerCAmelCase:	Optional[Any]   				=      mask_time_prob
						__lowerCAmelCase:	Union[str, Any]   				=      mask_time_length
						__lowerCAmelCase:	List[Any]   				=      mask_time_min_masks
						__lowerCAmelCase:	List[Any]   				=      mask_feature_prob
						__lowerCAmelCase:	List[str]   				=      mask_feature_length
						__lowerCAmelCase:	int   				=      mask_feature_min_masks

						# ctc loss
						__lowerCAmelCase:	int   				=      ctc_loss_reduction
						__lowerCAmelCase:	Any   				=      ctc_zero_infinity

						# adapter
						__lowerCAmelCase:	Dict   				=      add_adapter
						__lowerCAmelCase:	str   				=      adapter_kernel_size
						__lowerCAmelCase:	Optional[Any]   				=      adapter_stride
						__lowerCAmelCase:	Tuple   				=      num_adapter_layers
						__lowerCAmelCase:	List[str]   				=      output_hidden_size or hidden_size

						# SequenceClassification-specific parameter. Feel free to ignore for other classes.
						__lowerCAmelCase:	Optional[int]   				=      classifier_proj_size

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




				@property
				def 							lowercase_					(     self							:    Optional[Any])->       Optional[int]:



						'''simple docstring'''


						return math.prod(self.conv_stride)





"""simple docstring"""


from math import ceil






def    a__   (   __SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)     ->     str:
		__lowerCAmelCase:	Tuple   				=      list(range(0 ,			__SCREAMING_SNAKE_CASE			)			)

		__lowerCAmelCase:	Optional[Any]   				=      [item for sublist in list(device_map.values()			) for item in sublist]

		# Duplicate check
		__lowerCAmelCase:	List[Any]   				=      []
		for i in device_map_blocks:
				if device_map_blocks.count(__SCREAMING_SNAKE_CASE			) > 1 and i not in duplicate_blocks:
						duplicate_blocks.append(__SCREAMING_SNAKE_CASE			)
    # Missing blocks
		__lowerCAmelCase:	Optional[Any]   				=      [i for i in blocks if i not in device_map_blocks]
		__lowerCAmelCase:	List[Any]   				=      [i for i in device_map_blocks if i not in blocks]

		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
				    " These attention blocks were specified more than once: " + str(__SCREAMING_SNAKE_CASE			)			)
		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "There are attention blocks for this model that are not specified in the device_map. Add these attention "
				    "blocks to a device on the device_map: " + str(__SCREAMING_SNAKE_CASE			)			)
		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "The device_map contains more attention blocks than this model has. Remove these from the device_map:"
				    + str(__SCREAMING_SNAKE_CASE			)			)






def    a__   (   __SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)     ->     str:
		__lowerCAmelCase:	List[Any]   				=      list(range(__SCREAMING_SNAKE_CASE			)			)
		__lowerCAmelCase:	Dict   				=      int(ceil(n_layers / len(__SCREAMING_SNAKE_CASE			)			)			)
		__lowerCAmelCase:	Union[str, Any]   				=      [layers[i : i + n_blocks] for i in range(0 ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)]

		return dict(zip(__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)			)


