



import functools
import operator

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


lowercase_:  str     						=					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 						lowercase__      (__snake_case						):

     """simple docstring"""






     __UpperCamelCase    :	str		=       'wavlm'


     def __init__( self :	Optional[Any]   ,			__a :	Optional[int]=3_2   ,			__a :	int=7_6_8   ,			__a :	List[str]=1_2   ,			__a :	List[str]=1_2   ,			__a :	Union[str, Any]=3_0_7_2   ,			__a :	Optional[Any]="gelu"   ,			__a :	Union[str, Any]=0.1   ,			__a :	Any=0.1   ,			__a :	Optional[int]=0.1   ,			__a :	List[str]=0.0   ,			__a :	int=0.1   ,			__a :	List[str]=0.1   ,			__a :	int=0.02   ,			__a :	Optional[int]=1e-5   ,			__a :	Union[str, Any]="group"   ,			__a :	str="gelu"   ,			__a :	int=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)   ,			__a :	Tuple=(5, 2, 2, 2, 2, 2, 2)   ,			__a :	Tuple=(1_0, 3, 3, 3, 3, 2, 2)   ,			__a :	int=False   ,			__a :	str=1_2_8   ,			__a :	List[Any]=1_6   ,			__a :	List[str]=3_2_0   ,			__a :	Optional[Any]=8_0_0   ,			__a :	Dict=False   ,			__a :	Union[str, Any]=True   ,			__a :	Any=0.05   ,			__a :	int=1_0   ,			__a :	Dict=2   ,			__a :	Optional[int]=0.0   ,			__a :	Tuple=1_0   ,			__a :	Any=3_2_0   ,			__a :	Union[str, Any]=2   ,			__a :	List[Any]=0.1   ,			__a :	str=1_0_0   ,			__a :	Optional[int]=2_5_6   ,			__a :	Optional[int]=2_5_6   ,			__a :	Union[str, Any]=0.1   ,			__a :	Dict="mean"   ,			__a :	List[Any]=False   ,			__a :	Optional[int]=False   ,			__a :	Any=2_5_6   ,			__a :	Any=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)   ,			__a :	List[Any]=(5, 3, 3, 1, 1)   ,			__a :	str=(1, 2, 3, 1, 1)   ,			__a :	List[Any]=5_1_2   ,			__a :	int=8_0   ,			__a :	Tuple=0   ,			__a :	List[str]=1   ,			__a :	List[Any]=2   ,			__a :	Union[str, Any]=False   ,			__a :	Dict=3   ,			__a :	int=2   ,			__a :	Optional[int]=3   ,			__a :	int=None   ,			**__a :	Union[str, Any]   ,			):
      super().__init__(**__a   ,			pad_token_id=__a   ,			bos_token_id=__a   ,			eos_token_id=__a )
      snake_case__				:							int      							= hidden_size
      snake_case__				:							int      							= feat_extract_norm
      snake_case__				:							Union[str, Any]      							= feat_extract_activation
      snake_case__				:							List[str]      							= list(__a )
      snake_case__				:							Union[str, Any]      							= list(__a )
      snake_case__				:							int      							= list(__a )
      snake_case__				:							Tuple      							= conv_bias
      snake_case__				:							List[Any]      							= num_buckets
      snake_case__				:							List[str]      							= max_bucket_distance
      snake_case__				:							Optional[Any]      							= num_conv_pos_embeddings
      snake_case__				:							List[Any]      							= num_conv_pos_embedding_groups
      snake_case__				:							int      							= len(self.conv_dim )
      snake_case__				:							str      							= num_hidden_layers
      snake_case__				:							int      							= intermediate_size
      snake_case__				:							Dict      							= hidden_act
      snake_case__				:							str      							= num_attention_heads
      snake_case__				:							int      							= hidden_dropout
      snake_case__				:							Dict      							= attention_dropout
      snake_case__				:							Tuple      							= activation_dropout
      snake_case__				:							List[str]      							= feat_proj_dropout
      snake_case__				:							Any      							= final_dropout
      snake_case__				:							str      							= layerdrop
      snake_case__				:							Union[str, Any]      							= layer_norm_eps
      snake_case__				:							Tuple      							= initializer_range
      snake_case__				:							int      							= num_ctc_classes
      snake_case__				:							Any      							= vocab_size
      snake_case__				:							str      							= do_stable_layer_norm
      snake_case__				:							List[Any]      							= use_weighted_layer_sum
      snake_case__				:							List[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
      snake_case__				:							int      							= apply_spec_augment
      snake_case__				:							List[str]      							= mask_time_prob
      snake_case__				:							Optional[Any]      							= mask_time_length
      snake_case__				:							Union[str, Any]      							= mask_time_min_masks
      snake_case__				:							Any      							= mask_feature_prob
      snake_case__				:							str      							= mask_feature_length

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

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

      # adapter
      snake_case__				:							List[Any]      							= add_adapter
      snake_case__				:							Any      							= adapter_kernel_size
      snake_case__				:							Tuple      							= adapter_stride
      snake_case__				:							Union[str, Any]      							= num_adapter_layers
      snake_case__				:							Any      							= output_hidden_size or hidden_size

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

      # XVector-specific parameters. Feel free to ignore for other classes.
      snake_case__				:							Dict      							= list(__a )
      snake_case__				:							int      							= list(__a )
      snake_case__				:							Tuple      							= list(__a )
      snake_case__				:							Tuple      							= xvector_output_dim


     @property
     def 		lowercase   ( self :	str ):
      return functools.reduce(operator.mul   ,			self.conv_stride   ,			1 )








'''simple docstring'''






import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible






class    __magic_name__				(						unittest.TestCase							):






       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Any				       =[
              'safety_checker/pytorch_model.bin',
              'safety_checker/model.safetensors',
              'vae/diffusion_pytorch_model.bin',
              'vae/diffusion_pytorch_model.safetensors',
              'text_encoder/pytorch_model.bin',
              'text_encoder/model.safetensors',
              'unet/diffusion_pytorch_model.bin',
              'unet/diffusion_pytorch_model.safetensors',
          ]
          self.assertTrue(is_safetensors_compatible(snake_case))






       def      lowerCAmelCase						(     self)		->    List[str]:




          '''simple docstring'''
          _UpperCAmelCase  :  Optional[int]				       =[
              'unet/diffusion_pytorch_model.bin',
              'unet/diffusion_pytorch_model.safetensors',
          ]
          self.assertTrue(is_safetensors_compatible(snake_case))






       def      lowerCAmelCase						(     self)		->    Any:




          '''simple docstring'''
          _UpperCAmelCase  :  Union[str, Any]				       =[
              'safety_checker/pytorch_model.bin',
              'safety_checker/model.safetensors',
              'vae/diffusion_pytorch_model.bin',
              'vae/diffusion_pytorch_model.safetensors',
              'text_encoder/pytorch_model.bin',
              'text_encoder/model.safetensors',
              'unet/diffusion_pytorch_model.bin',
              # Removed: 'unet/diffusion_pytorch_model.safetensors',
          ]
          self.assertFalse(is_safetensors_compatible(snake_case))






       def      lowerCAmelCase						(     self)		->    Dict:




          '''simple docstring'''
          _UpperCAmelCase  :  int				       =[
              'text_encoder/pytorch_model.bin',
              'text_encoder/model.safetensors',
          ]
          self.assertTrue(is_safetensors_compatible(snake_case))






       def      lowerCAmelCase						(     self)		->    Any:




          '''simple docstring'''
          _UpperCAmelCase  :  Any				       =[
              'safety_checker/pytorch_model.bin',
              'safety_checker/model.safetensors',
              'vae/diffusion_pytorch_model.bin',
              'vae/diffusion_pytorch_model.safetensors',
              'text_encoder/pytorch_model.bin',
              # Removed: 'text_encoder/model.safetensors',
              'unet/diffusion_pytorch_model.bin',
              'unet/diffusion_pytorch_model.safetensors',
          ]
          self.assertFalse(is_safetensors_compatible(snake_case))






       def      lowerCAmelCase						(     self)		->    List[Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Union[str, Any]				       =[
              'safety_checker/pytorch_model.fp16.bin',
              'safety_checker/model.fp16.safetensors',
              'vae/diffusion_pytorch_model.fp16.bin',
              'vae/diffusion_pytorch_model.fp16.safetensors',
              'text_encoder/pytorch_model.fp16.bin',
              'text_encoder/model.fp16.safetensors',
              'unet/diffusion_pytorch_model.fp16.bin',
              'unet/diffusion_pytorch_model.fp16.safetensors',
          ]
          _UpperCAmelCase  :  str				       ='fp16'
          self.assertTrue(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Tuple				       =[
              'unet/diffusion_pytorch_model.fp16.bin',
              'unet/diffusion_pytorch_model.fp16.safetensors',
          ]
          _UpperCAmelCase  :  int				       ='fp16'
          self.assertTrue(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    Optional[int]:




          '''simple docstring'''
          # pass variant but use the non-variant filenames
          _UpperCAmelCase  :  Optional[int]				       =[
              'unet/diffusion_pytorch_model.bin',
              'unet/diffusion_pytorch_model.safetensors',
          ]
          _UpperCAmelCase  :  Optional[Any]				       ='fp16'
          self.assertTrue(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    int:




          '''simple docstring'''
          _UpperCAmelCase  :  str				       =[
              'safety_checker/pytorch_model.fp16.bin',
              'safety_checker/model.fp16.safetensors',
              'vae/diffusion_pytorch_model.fp16.bin',
              'vae/diffusion_pytorch_model.fp16.safetensors',
              'text_encoder/pytorch_model.fp16.bin',
              'text_encoder/model.fp16.safetensors',
              'unet/diffusion_pytorch_model.fp16.bin',
              # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
          ]
          _UpperCAmelCase  :  List[str]				       ='fp16'
          self.assertFalse(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  Dict				       =[
              'text_encoder/pytorch_model.fp16.bin',
              'text_encoder/model.fp16.safetensors',
          ]
          _UpperCAmelCase  :  Optional[Any]				       ='fp16'
          self.assertTrue(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    Any:




          '''simple docstring'''
          # pass variant but use the non-variant filenames
          _UpperCAmelCase  :  Optional[int]				       =[
              'text_encoder/pytorch_model.bin',
              'text_encoder/model.safetensors',
          ]
          _UpperCAmelCase  :  List[Any]				       ='fp16'
          self.assertTrue(is_safetensors_compatible(snake_case    ,				variant=snake_case))






       def      lowerCAmelCase						(     self)		->    Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase  :  str				       =[
              'safety_checker/pytorch_model.fp16.bin',
              'safety_checker/model.fp16.safetensors',
              'vae/diffusion_pytorch_model.fp16.bin',
              'vae/diffusion_pytorch_model.fp16.safetensors',
              'text_encoder/pytorch_model.fp16.bin',
              # 'text_encoder/model.fp16.safetensors',
              'unet/diffusion_pytorch_model.fp16.bin',
              'unet/diffusion_pytorch_model.fp16.safetensors',
          ]
          _UpperCAmelCase  :  Tuple				       ='fp16'
          self.assertFalse(is_safetensors_compatible(snake_case    ,				variant=snake_case))

