





"""simple docstring"""




import math

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


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

a						: Dict     	=			{
    '''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__						):
							lowerCamelCase   :					Optional[int]      					="""data2vec-audio"""






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

								# ctc loss
								a      :		Optional[int]	=				ctc_loss_reduction
								a      :		int	=				ctc_zero_infinity

								# adapter
								a      :		str	=				add_adapter
								a      :		Any	=				adapter_kernel_size
								a      :		Any	=				adapter_stride
								a      :		str	=				num_adapter_layers
								a      :		str	=				output_hidden_size or hidden_size

								# 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      :		Optional[int]	=				list(lowerCAmelCase__      )
								a      :		List[Any]	=				list(lowerCAmelCase__      )
								a      :		Dict	=				list(lowerCAmelCase__      )
								a      :		Tuple	=				xvector_output_dim






							@property
							def     __a   (   self      )	-> Union[str, Any]:
								return math.prod(self.conv_stride      )









"""simple docstring"""




import unittest
from dataclasses import dataclass

import pytest

from accelerate.commands.config.config_args import SageMakerConfig
from accelerate.utils import ComputeEnvironment
from accelerate.utils.launch import _convert_nargs_to_dict


@dataclass
class        __UpperCamelCase				(						a__						):
							lowerCamelCase   :					List[str]      					=ComputeEnvironment.AMAZON_SAGEMAKER
							lowerCamelCase   :					str      					=True
							lowerCamelCase   :					Union[str, Any]      					="""ml.p3.2xlarge"""
							lowerCamelCase   :					str      					="""accelerate_sagemaker_execution_role"""
							lowerCamelCase   :					int      					="""hf-sm"""
							lowerCamelCase   :					int      					="""us-east-1"""
							lowerCamelCase   :					Tuple      					=1
							lowerCamelCase   :					Any      					="""accelerate-sagemaker-1"""
							lowerCamelCase   :					str      					="""1.6"""
							lowerCamelCase   :					Tuple      					="""4.4"""
							lowerCamelCase   :					Optional[int]      					="""train.py"""
							lowerCamelCase   :					Optional[Any]      					=[
							    """--model_name_or_path""",
							    """bert""",
							    """--do_train""",
							    """False""",
							    """--epochs""",
							    """3""",
							    """--learning_rate""",
							    """5e-5""",
							    """--max_steps""",
							    """50.5""",
							]
							lowerCamelCase   :					Union[str, Any]      					=[
							    """--model_name_or_path""",
							    """bert""",
							    """--do_train""",
							    """--do_test""",
							    """False""",
							    """--do_predict""",
							    """--epochs""",
							    """3""",
							    """--learning_rate""",
							    """5e-5""",
							    """--max_steps""",
							    """50.5""",
							]


class        __UpperCamelCase				(						unittest.TestCase						):






							def     __a   (   self      )	-> List[str]:
								# If no defaults are changed, `to_kwargs` returns an empty dict.
								a      :		str	=				_convert_nargs_to_dict(MockLaunchConfig.success_training_script_args      )
								assert isinstance(converted_args["model_name_or_path"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["do_train"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["epochs"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["learning_rate"]      ,					lowerCAmelCase__      )
								assert isinstance(converted_args["max_steps"]      ,					lowerCAmelCase__      )

								with pytest.raises(lowerCAmelCase__      ):
									_convert_nargs_to_dict(MockLaunchConfig.fail_training_script_args      )


