


'''simple docstring'''






import functools
import operator

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


__UpperCAmelCase       							=				logging.get_logger(__name__)

__UpperCAmelCase       							=				{
    '''microsoft/wavlm-base''': '''https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json''',
    # See all WavLM models at https://huggingface.co/models?filter=wavlm
}




class 						a__							(				a__    ):





							'''simple docstring'''






							lowercase__     :  List[str]      		= "wavlm"







							def __init__(						self   ,       lowerCamelCase_=32   ,       lowerCamelCase_=7_68   ,       lowerCamelCase_=12   ,       lowerCamelCase_=12   ,       lowerCamelCase_=30_72   ,       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_="group"   ,       lowerCamelCase_="gelu"   ,       lowerCamelCase_=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)   ,       lowerCamelCase_=(5, 2, 2, 2, 2, 2, 2)   ,       lowerCamelCase_=(10, 3, 3, 3, 3, 2, 2)   ,       lowerCamelCase_=False   ,       lowerCamelCase_=1_28   ,       lowerCamelCase_=16   ,       lowerCamelCase_=3_20   ,       lowerCamelCase_=8_00   ,       lowerCamelCase_=False   ,       lowerCamelCase_=True   ,       lowerCamelCase_=0.05   ,       lowerCamelCase_=10   ,       lowerCamelCase_=2   ,       lowerCamelCase_=0.0   ,       lowerCamelCase_=10   ,       lowerCamelCase_=3_20   ,       lowerCamelCase_=2   ,       lowerCamelCase_=0.1   ,       lowerCamelCase_=1_00   ,       lowerCamelCase_=2_56   ,       lowerCamelCase_=2_56   ,       lowerCamelCase_=0.1   ,       lowerCamelCase_="mean"   ,       lowerCamelCase_=False   ,       lowerCamelCase_=False   ,       lowerCamelCase_=2_56   ,       lowerCamelCase_=(5_12, 5_12, 5_12, 5_12, 15_00)   ,       lowerCamelCase_=(5, 3, 3, 1, 1)   ,       lowerCamelCase_=(1, 2, 3, 1, 1)   ,       lowerCamelCase_=5_12   ,       lowerCamelCase_=80   ,       lowerCamelCase_=0   ,       lowerCamelCase_=1   ,       lowerCamelCase_=2   ,       lowerCamelCase_=False   ,       lowerCamelCase_=3   ,       lowerCamelCase_=2   ,       lowerCamelCase_=3   ,       lowerCamelCase_=None   ,       **lowerCamelCase_   ,       )			->				Optional[int]:
														super().__init__(**lowerCamelCase_   ,       pad_token_id=lowerCamelCase_   ,       bos_token_id=lowerCamelCase_   ,       eos_token_id=lowerCamelCase_  )
														lowerCAmelCase__			  =      hidden_size
														lowerCAmelCase__			  =      feat_extract_norm
														lowerCAmelCase__			  =      feat_extract_activation
														lowerCAmelCase__			  =      list(lowerCamelCase_  )
														lowerCAmelCase__			  =      list(lowerCamelCase_  )
														lowerCAmelCase__			  =      list(lowerCamelCase_  )
														lowerCAmelCase__			  =      conv_bias
														lowerCAmelCase__			  =      num_buckets
														lowerCAmelCase__			  =      max_bucket_distance
														lowerCAmelCase__			  =      num_conv_pos_embeddings
														lowerCAmelCase__			  =      num_conv_pos_embedding_groups
														lowerCAmelCase__			  =      len(self.conv_dim  )
														lowerCAmelCase__			  =      num_hidden_layers
														lowerCAmelCase__			  =      intermediate_size
														lowerCAmelCase__			  =      hidden_act
														lowerCAmelCase__			  =      num_attention_heads
														lowerCAmelCase__			  =      hidden_dropout
														lowerCAmelCase__			  =      attention_dropout
														lowerCAmelCase__			  =      activation_dropout
														lowerCAmelCase__			  =      feat_proj_dropout
														lowerCAmelCase__			  =      final_dropout
														lowerCAmelCase__			  =      layerdrop
														lowerCAmelCase__			  =      layer_norm_eps
														lowerCAmelCase__			  =      initializer_range
														lowerCAmelCase__			  =      num_ctc_classes
														lowerCAmelCase__			  =      vocab_size
														lowerCAmelCase__			  =      do_stable_layer_norm
														lowerCAmelCase__			  =      use_weighted_layer_sum
														lowerCAmelCase__			  =      classifier_proj_size

														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__			  =      apply_spec_augment
														lowerCAmelCase__			  =      mask_time_prob
														lowerCAmelCase__			  =      mask_time_length
														lowerCAmelCase__			  =      mask_time_min_masks
														lowerCAmelCase__			  =      mask_feature_prob
														lowerCAmelCase__			  =      mask_feature_length

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

														# ctc loss
														lowerCAmelCase__			  =      ctc_loss_reduction
														lowerCAmelCase__			  =      ctc_zero_infinity

														# adapter
														lowerCAmelCase__			  =      add_adapter
														lowerCAmelCase__			  =      adapter_kernel_size
														lowerCAmelCase__			  =      adapter_stride
														lowerCAmelCase__			  =      num_adapter_layers
														lowerCAmelCase__			  =      output_hidden_size or hidden_size

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

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







							@property
							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Optional[Any]:
														return functools.reduce(operator.mul   ,       self.conv_stride   ,       1  )



'''simple docstring'''






# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


__UpperCAmelCase       							=				[
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]


def    _snake_case  (	A					,       A=None					,       A=None					,       A=None			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      True
							while ask_again:
														lowerCAmelCase__			  =      input(A			)
														try:
																					if default is not None and len(A			) == 0:
																												return default
																					return convert_value(A			) if convert_value is not None else result
														except Exception:
																					if error_message is not None:
																												print(A			)


def    _snake_case  (	A					,       A=[]					,       A=None					,       A=0			)		->       List[Any]:
							lowerCAmelCase__			  =      BulletMenu(A					,       A			)
							lowerCAmelCase__			  =      menu.run(default_choice=A			)
							return convert_value(A			) if convert_value is not None else result


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]			)


def    _snake_case  (	A			)		->       str:
							lowerCAmelCase__			  =      int(A			)
							return DynamoBackend(DYNAMO_BACKENDS[value]			).value


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]			)


def    _snake_case  (	A			)		->       List[str]:
							return {"yes": True, "no": False}[value.lower()]






class 						a__							(				argparse.RawDescriptionHelpFormatter    ):





							'''simple docstring'''






							def     __SCREAMING_SNAKE_CASE				(						self   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )			->				Dict:
														lowerCAmelCase__			  =      super()._format_usage(lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )
														lowerCAmelCase__			  =      usage.replace('''<command> [<args>] '''   ,       ''''''  )
														return usage