



import functools
import operator

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


A   :					int	=      logging.get_logger(__name__)

A   :					List[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     _lowercase				(							lowercase__):


       """simple docstring"""




       A__      		=    "wavlm"





       def __init__(     self							:    str      ,   __lowerCamelCase							:    Tuple=32      ,   __lowerCamelCase							:    Optional[Any]=768      ,   __lowerCamelCase							:    Optional[Any]=12      ,   __lowerCamelCase							:    Union[str, Any]=12      ,   __lowerCamelCase							:    Any=3072      ,   __lowerCamelCase							:    str="gelu"      ,   __lowerCamelCase							:    Dict=0.1      ,   __lowerCamelCase							:    Any=0.1      ,   __lowerCamelCase							:    List[Any]=0.1      ,   __lowerCamelCase							:    List[str]=0.0      ,   __lowerCamelCase							:    str=0.1      ,   __lowerCamelCase							:    str=0.1      ,   __lowerCamelCase							:    Dict=0.0_2      ,   __lowerCamelCase							:    List[str]=1E-5      ,   __lowerCamelCase							:    Optional[Any]="group"      ,   __lowerCamelCase							:    Dict="gelu"      ,   __lowerCamelCase							:    List[Any]=(512, 512, 512, 512, 512, 512, 512)      ,   __lowerCamelCase							:    Union[str, Any]=(5, 2, 2, 2, 2, 2, 2)      ,   __lowerCamelCase							:    int=(10, 3, 3, 3, 3, 2, 2)      ,   __lowerCamelCase							:    str=False      ,   __lowerCamelCase							:    Union[str, Any]=128      ,   __lowerCamelCase							:    Dict=16      ,   __lowerCamelCase							:    Optional[Any]=320      ,   __lowerCamelCase							:    int=800      ,   __lowerCamelCase							:    Tuple=False      ,   __lowerCamelCase							:    Optional[Any]=True      ,   __lowerCamelCase							:    Optional[Any]=0.0_5      ,   __lowerCamelCase							:    int=10      ,   __lowerCamelCase							:    Optional[int]=2      ,   __lowerCamelCase							:    Tuple=0.0      ,   __lowerCamelCase							:    List[str]=10      ,   __lowerCamelCase							:    List[Any]=320      ,   __lowerCamelCase							:    Dict=2      ,   __lowerCamelCase							:    Any=0.1      ,   __lowerCamelCase							:    Union[str, Any]=100      ,   __lowerCamelCase							:    Any=256      ,   __lowerCamelCase							:    Dict=256      ,   __lowerCamelCase							:    Any=0.1      ,   __lowerCamelCase							:    int="mean"      ,   __lowerCamelCase							:    Optional[int]=False      ,   __lowerCamelCase							:    int=False      ,   __lowerCamelCase							:    Dict=256      ,   __lowerCamelCase							:    Dict=(512, 512, 512, 512, 1500)      ,   __lowerCamelCase							:    List[Any]=(5, 3, 3, 1, 1)      ,   __lowerCamelCase							:    Any=(1, 2, 3, 1, 1)      ,   __lowerCamelCase							:    List[str]=512      ,   __lowerCamelCase							:    Optional[Any]=80      ,   __lowerCamelCase							:    Dict=0      ,   __lowerCamelCase							:    int=1      ,   __lowerCamelCase							:    Optional[Any]=2      ,   __lowerCamelCase							:    int=False      ,   __lowerCamelCase							:    List[str]=3      ,   __lowerCamelCase							:    Dict=2      ,   __lowerCamelCase							:    List[str]=3      ,   __lowerCamelCase							:    int=None      ,   **__lowerCamelCase							:    Any      ,   ):


             '''simple docstring'''



             super().__init__(**__lowerCamelCase      ,   pad_token_id=__lowerCamelCase      ,   bos_token_id=__lowerCamelCase      ,   eos_token_id=__lowerCamelCase )
             lowerCamelCase__	:       List[Any]					=						hidden_size
             lowerCamelCase__	:       Union[str, Any]					=						feat_extract_norm
             lowerCamelCase__	:       List[Any]					=						feat_extract_activation
             lowerCamelCase__	:       Any					=						list(__lowerCamelCase )
             lowerCamelCase__	:       Optional[int]					=						list(__lowerCamelCase )
             lowerCamelCase__	:       List[Any]					=						list(__lowerCamelCase )
             lowerCamelCase__	:       Tuple					=						conv_bias
             lowerCamelCase__	:       Union[str, Any]					=						num_buckets
             lowerCamelCase__	:       Dict					=						max_bucket_distance
             lowerCamelCase__	:       Optional[Any]					=						num_conv_pos_embeddings
             lowerCamelCase__	:       str					=						num_conv_pos_embedding_groups
             lowerCamelCase__	:       int					=						len(self.conv_dim )
             lowerCamelCase__	:       List[str]					=						num_hidden_layers
             lowerCamelCase__	:       Optional[int]					=						intermediate_size
             lowerCamelCase__	:       List[str]					=						hidden_act
             lowerCamelCase__	:       int					=						num_attention_heads
             lowerCamelCase__	:       Union[str, Any]					=						hidden_dropout
             lowerCamelCase__	:       Union[str, Any]					=						attention_dropout
             lowerCamelCase__	:       Dict					=						activation_dropout
             lowerCamelCase__	:       Dict					=						feat_proj_dropout
             lowerCamelCase__	:       Any					=						final_dropout
             lowerCamelCase__	:       List[Any]					=						layerdrop
             lowerCamelCase__	:       Tuple					=						layer_norm_eps
             lowerCamelCase__	:       str					=						initializer_range
             lowerCamelCase__	:       Tuple					=						num_ctc_classes
             lowerCamelCase__	:       str					=						vocab_size
             lowerCamelCase__	:       Union[str, Any]					=						do_stable_layer_norm
             lowerCamelCase__	:       int					=						use_weighted_layer_sum
             lowerCamelCase__	:       int					=						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__	:       Union[str, Any]					=						apply_spec_augment
             lowerCamelCase__	:       Optional[int]					=						mask_time_prob
             lowerCamelCase__	:       List[str]					=						mask_time_length
             lowerCamelCase__	:       int					=						mask_time_min_masks
             lowerCamelCase__	:       Optional[int]					=						mask_feature_prob
             lowerCamelCase__	:       List[Any]					=						mask_feature_length

             # parameters for pretraining with codevector quantized representations
             lowerCamelCase__	:       int					=						num_codevectors_per_group
             lowerCamelCase__	:       List[Any]					=						num_codevector_groups
             lowerCamelCase__	:       List[str]					=						contrastive_logits_temperature
             lowerCamelCase__	:       str					=						num_negatives
             lowerCamelCase__	:       Optional[Any]					=						codevector_dim
             lowerCamelCase__	:       str					=						proj_codevector_dim
             lowerCamelCase__	:       List[Any]					=						diversity_loss_weight

             # ctc loss
             lowerCamelCase__	:       List[Any]					=						ctc_loss_reduction
             lowerCamelCase__	:       Optional[int]					=						ctc_zero_infinity

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

             # SequenceClassification-specific parameter. Feel free to ignore for other classes.
             lowerCamelCase__	:       Any					=						classifier_proj_size

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





       @property
       def 		lowerCAmelCase  (     self							:    Optional[Any] ):


             '''simple docstring'''



             return functools.reduce(operator.mul      ,   self.conv_stride      ,   1 )






import os
from pathlib import Path

def    lowercase_	(	):

      """simple docstring"""




      from torch.utils.cpp_extension import load

      lowerCamelCase__	:       Any					=						Path(_A		).resolve().parent.parent.parent / "kernels" / "deformable_detr"
      lowerCamelCase__	:       Optional[int]					=						[
          root / filename
          for filename in [
              "vision.cpp",
              os.path.join("cpu"					,      "ms_deform_attn_cpu.cpp"		),
              os.path.join("cuda"					,      "ms_deform_attn_cuda.cu"		),
          ]
      ]

      load(
          "MultiScaleDeformableAttention"					,      _A					,      with_cuda=_A					,      extra_include_paths=[str(_A		)]					,      extra_cflags=["-DWITH_CUDA=1"]					,      extra_cuda_cflags=[
              "-DCUDA_HAS_FP16=1",
              "-D__CUDA_NO_HALF_OPERATORS__",
              "-D__CUDA_NO_HALF_CONVERSIONS__",
              "-D__CUDA_NO_HALF2_OPERATORS__",
          ]					,      )

      import MultiScaleDeformableAttention as MSDA

      return MSDA


