





'''simple docstring'''

import functools
import operator

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


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

__lowerCAmelCase							:     List[Any]		     ={
    "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json",
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}






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

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

     # ctc loss
     A__    =      ctc_loss_reduction
     A__    =      ctc_zero_infinity

     # adapter
     A__    =      add_adapter
     A__    =      adapter_kernel_size
     A__    =      adapter_stride
     A__    =      num_adapter_layers
     A__    =      output_hidden_size or hidden_size
     A__    =      adapter_attn_dim

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

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



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










'''simple docstring'''

import argparse
import os
import re

import packaging.version


__lowerCAmelCase							:     List[Any]		     ="examples/"
__lowerCAmelCase							:     Dict		     ={
    "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
    "init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$", re.MULTILINE), "__version__ = \"VERSION\"\n"),
    "setup": (re.compile(R"^(\s*)version\s*=\s*\"[^\"]+\",", re.MULTILINE), R"\1version=\"VERSION\","),
    "doc": (re.compile(R"^(\s*)release\s*=\s*\"[^\"]+\"$", re.MULTILINE), "release = \"VERSION\"\n"),
}
__lowerCAmelCase							:     List[str]		     ={
    "init": "src/transformers/__init__.py",
    "setup": "setup.py",
}
__lowerCAmelCase							:     str		     ="README.md"





def 						UpperCamelCase    (							_lowerCamelCase : Optional[Any]						,	_lowerCamelCase : Union[str, Any]						,	_lowerCamelCase : Optional[Any]	):
    with open(_lowerCamelCase						,	"r"						,	encoding="utf-8"						,	newline="\n"	) as f:
        A__    =      f.read()
    A__,     A__    =      REPLACE_PATTERNS[pattern]
    A__    =      replace.replace("VERSION"						,	_lowerCamelCase	)
    A__    =      re_pattern.sub(_lowerCamelCase						,	_lowerCamelCase	)
    with open(_lowerCamelCase						,	"w"						,	encoding="utf-8"						,	newline="\n"	) as f:
        f.write(_lowerCamelCase	)





def 						UpperCamelCase    (							_lowerCamelCase : int	):
    for folder, directories, fnames in os.walk(_lowerCamelCase	):
        # Removing some of the folders with non-actively maintained examples from the walk
        if "research_projects" in directories:
            directories.remove("research_projects"	)
        if "legacy" in directories:
            directories.remove("legacy"	)
        for fname in fnames:
            if fname.endswith(".py"	):
                update_version_in_file(os.path.join(_lowerCamelCase						,	_lowerCamelCase	)						,	_lowerCamelCase						,	pattern="examples"	)





def 						UpperCamelCase    (							_lowerCamelCase : int						,	_lowerCamelCase : Union[str, Any]=False	):
    for pattern, fname in REPLACE_FILES.items():
        update_version_in_file(_lowerCamelCase						,	_lowerCamelCase						,	_lowerCamelCase	)
    if not patch:
        update_version_in_examples(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    A__    =      "🤗 Transformers currently provides the following architectures"
    A__    =      "1. Want to contribute a new model?"
    with open(_lowerCamelCase						,	"r"						,	encoding="utf-8"						,	newline="\n"	) as f:
        A__    =      f.readlines()

    # Find the start of the list.
    A__    =      0
    while not lines[start_index].startswith(_start_prompt	):
        start_index += 1
    start_index += 1

    A__    =      start_index
    # Update the lines in the model list.
    while not lines[index].startswith(_end_prompt	):
        if lines[index].startswith("1."	):
            A__    =      lines[index].replace(
                "https://huggingface.co/docs/transformers/main/model_doc"						,	"https://huggingface.co/docs/transformers/model_doc"						,	)
        index += 1

    with open(_lowerCamelCase						,	"w"						,	encoding="utf-8"						,	newline="\n"	) as f:
        f.writelines(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    with open(REPLACE_FILES["init"]						,	"r"	) as f:
        A__    =      f.read()
    A__    =      REPLACE_PATTERNS["init"][0].search(_lowerCamelCase	).groups()[0]
    return packaging.version.parse(_lowerCamelCase	)





def 						UpperCamelCase    (							_lowerCamelCase : Dict=False	):
    A__    =      get_version()
    if patch and default_version.is_devrelease:
        raise ValueError("Can't create a patch version from the dev branch, checkout a released version!"	)
    if default_version.is_devrelease:
        A__    =      default_version.base_version
    elif patch:
        A__    =      F"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
    else:
        A__    =      F"{default_version.major}.{default_version.minor + 1}.0"

    # Now let's ask nicely if that's the right one.
    A__    =      input(F"Which version are you releasing? [{default_version}]"	)
    if len(_lowerCamelCase	) == 0:
        A__    =      default_version

    print(F"Updating version to {version}."	)
    global_version_update(_lowerCamelCase						,	patch=_lowerCamelCase	)
    if not patch:
        print("Cleaning main README, don't forget to run `make fix-copies`."	)
        clean_main_ref_in_model_list()





def 						UpperCamelCase    (							):
    A__    =      get_version()
    A__    =      F"{current_version.major}.{current_version.minor + 1}.0.dev0"
    A__    =      current_version.base_version

    # Check with the user we got that right.
    A__    =      input(F"Which version are we developing now? [{dev_version}]"	)
    if len(_lowerCamelCase	) == 0:
        A__    =      dev_version

    print(F"Updating version to {version}."	)
    global_version_update(_lowerCamelCase	)
    print("Cleaning main README, don't forget to run `make fix-copies`."	)
    clean_main_ref_in_model_list()


if __name__ == "__main__":
  __lowerCAmelCase							:     Union[str, Any]		     =argparse.ArgumentParser()
  parser.add_argument("--post_release", action="store_true", help="Whether this is pre or post release.")
  parser.add_argument("--patch", action="store_true", help="Whether or not this is a patch release.")
  __lowerCAmelCase							:     int		     =parser.parse_args()
  if not args.post_release:
    pre_release_work(patch=args.patch)
  elif args.patch:
    print("Nothing to do after a patch :-)")
  else:
    post_release_work()



