import functools
import operator

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


_lowercase							:      int      							=logging.get_logger(__name__)

_lowercase							:      str      							={
    '''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  SCREAMING_SNAKE_CASE_ (					lowerCAmelCase_			):
  '''simple docstring'''


  lowercase		:     Dict            =				"wavlm"







  def __init__(				self    :					str      ,	SCREAMING_SNAKE_CASE__    :					str=32      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=7_68      ,	SCREAMING_SNAKE_CASE__    :					Tuple=12      ,	SCREAMING_SNAKE_CASE__    :					Dict=12      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=30_72      ,	SCREAMING_SNAKE_CASE__    :					str="gelu"      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=0.0      ,	SCREAMING_SNAKE_CASE__    :					List[str]=0.1      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					Tuple=0.0_2      ,	SCREAMING_SNAKE_CASE__    :					int=1e-5      ,	SCREAMING_SNAKE_CASE__    :					Dict="group"      ,	SCREAMING_SNAKE_CASE__    :					List[Any]="gelu"      ,	SCREAMING_SNAKE_CASE__    :					str=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=(5, 2, 2, 2, 2, 2, 2)      ,	SCREAMING_SNAKE_CASE__    :					str=(10, 3, 3, 3, 3, 2, 2)      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=False      ,	SCREAMING_SNAKE_CASE__    :					Tuple=1_28      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=16      ,	SCREAMING_SNAKE_CASE__    :					Tuple=3_20      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=8_00      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=False      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=True      ,	SCREAMING_SNAKE_CASE__    :					List[str]=0.0_5      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=10      ,	SCREAMING_SNAKE_CASE__    :					Dict=2      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.0      ,	SCREAMING_SNAKE_CASE__    :					str=10      ,	SCREAMING_SNAKE_CASE__    :					int=3_20      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=2      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					Dict=1_00      ,	SCREAMING_SNAKE_CASE__    :					Tuple=2_56      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=2_56      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=0.1      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]="mean"      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=False      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=False      ,	SCREAMING_SNAKE_CASE__    :					Any=2_56      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=(5_12, 5_12, 5_12, 5_12, 15_00)      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=(5, 3, 3, 1, 1)      ,	SCREAMING_SNAKE_CASE__    :					Dict=(1, 2, 3, 1, 1)      ,	SCREAMING_SNAKE_CASE__    :					Tuple=5_12      ,	SCREAMING_SNAKE_CASE__    :					Any=80      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=0      ,	SCREAMING_SNAKE_CASE__    :					List[str]=1      ,	SCREAMING_SNAKE_CASE__    :					Tuple=2      ,	SCREAMING_SNAKE_CASE__    :					Dict=False      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]=3      ,	SCREAMING_SNAKE_CASE__    :					str=2      ,	SCREAMING_SNAKE_CASE__    :					Tuple=3      ,	SCREAMING_SNAKE_CASE__    :					Any=None      ,	**SCREAMING_SNAKE_CASE__    :					List[Any]      ,	)    ->				int:
         super().__init__(**SCREAMING_SNAKE_CASE__      ,	pad_token_id=SCREAMING_SNAKE_CASE__      ,	bos_token_id=SCREAMING_SNAKE_CASE__      ,	eos_token_id=SCREAMING_SNAKE_CASE__     )
         A						:     Tuple         =hidden_size
         A						:     Union[str, Any]         =feat_extract_norm
         A						:     Tuple         =feat_extract_activation
         A						:     Any         =list(SCREAMING_SNAKE_CASE__     )
         A						:     Union[str, Any]         =list(SCREAMING_SNAKE_CASE__     )
         A						:     str         =list(SCREAMING_SNAKE_CASE__     )
         A						:     List[str]         =conv_bias
         A						:     List[Any]         =num_buckets
         A						:     str         =max_bucket_distance
         A						:     int         =num_conv_pos_embeddings
         A						:     Tuple         =num_conv_pos_embedding_groups
         A						:     Any         =len(self.conv_dim     )
         A						:     Any         =num_hidden_layers
         A						:     Optional[Any]         =intermediate_size
         A						:     Union[str, Any]         =hidden_act
         A						:     Optional[int]         =num_attention_heads
         A						:     Dict         =hidden_dropout
         A						:     Optional[Any]         =attention_dropout
         A						:     Optional[Any]         =activation_dropout
         A						:     Optional[Any]         =feat_proj_dropout
         A						:     Union[str, Any]         =final_dropout
         A						:     Union[str, Any]         =layerdrop
         A						:     Optional[Any]         =layer_norm_eps
         A						:     Any         =initializer_range
         A						:     List[str]         =num_ctc_classes
         A						:     Dict         =vocab_size
         A						:     List[str]         =do_stable_layer_norm
         A						:     Dict         =use_weighted_layer_sum
         A						:     Optional[Any]         =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
         A						:     str         =apply_spec_augment
         A						:     Any         =mask_time_prob
         A						:     Any         =mask_time_length
         A						:     int         =mask_time_min_masks
         A						:     str         =mask_feature_prob
         A						:     Optional[int]         =mask_feature_length

         # parameters for pretraining with codevector quantized representations
         A						:     Union[str, Any]         =num_codevectors_per_group
         A						:     Optional[Any]         =num_codevector_groups
         A						:     List[Any]         =contrastive_logits_temperature
         A						:     str         =num_negatives
         A						:     Any         =codevector_dim
         A						:     Dict         =proj_codevector_dim
         A						:     List[Any]         =diversity_loss_weight

         # ctc loss
         A						:     int         =ctc_loss_reduction
         A						:     int         =ctc_zero_infinity

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

         # SequenceClassification-specific parameter. Feel free to ignore for other classes.
         A						:     List[str]         =classifier_proj_size

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







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







# 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
import os

from accelerate.utils import ComputeEnvironment

from .cluster import get_cluster_input
from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file  # noqa: F401
from .config_utils import _ask_field, _ask_options, _convert_compute_environment  # noqa: F401
from .sagemaker import get_sagemaker_input


_lowercase							:      List[str]      							='''Launches a series of prompts to create and save a `default_config.yaml` configuration file for your training system. Should always be ran first on your machine'''



def A__  (			)				->		List[Any]:
       A						:     Any         =_ask_options(
           'In which compute environment are you running?',		['This machine', 'AWS (Amazon SageMaker)'],		_convert_compute_environment,		)
       if compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
              A						:     Tuple         =get_sagemaker_input()
       else:
              A						:     str         =get_cluster_input()
       return config



def A__  (			lowercase:     int=None					)				->		str:
       if subparsers is not None:
              A						:     List[str]         =subparsers.add_parser('config',		description=lowercase					)
       else:
              A						:     Union[str, Any]         =argparse.ArgumentParser('Accelerate config command',		description=lowercase					)

       parser.add_argument(
           '--config_file',		default=lowercase,		help=(
               'The path to use to store the config file. Will default to a file named default_config.yaml in the cache '
               'location, which is the content of the environment `HF_HOME` suffixed with \'accelerate\', or if you don\'t have '
               'such an environment variable, your cache directory (\'~/.cache\' or the content of `XDG_CACHE_HOME`) suffixed '
               'with \'huggingface\'.'
           ),		)

       if subparsers is not None:
              parser.set_defaults(func=lowercase					)
       return parser



def A__  (			lowercase:     Tuple					)				->		List[Any]:
       A						:     Union[str, Any]         =get_user_input()
       if args.config_file is not None:
              A						:     Optional[Any]         =args.config_file
       else:
              if not os.path.isdir(lowercase					):
                     os.makedirs(lowercase					)
              A						:     Union[str, Any]         =default_yaml_config_file

       if config_file.endswith('.json'					):
              config.to_json_file(lowercase					)
       else:
              config.to_yaml_file(lowercase					)
       print(F'accelerate configuration saved at {config_file}'					)



def A__  (			)				->		Optional[int]:
       A						:     Any         =config_command_parser()
       A						:     int         =parser.parse_args()
       config_command(lowercase					)


if __name__ == "__main__":
    main()






