



import functools
import operator

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


__snake_case						:Any      		=     logging.get_logger(__name__)

__snake_case						:int      		=     {
    '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json''',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}

class     _A       (	__UpperCAmelCase    ):
       UpperCamelCase__  :    Optional[int]											=						'''sew-d'''



       def __init__(		self							:     Union[str, Any]     ,		__SCREAMING_SNAKE_CASE							:     int=32     ,		__SCREAMING_SNAKE_CASE							:     List[Any]=768     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]=12     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]=12     ,		__SCREAMING_SNAKE_CASE							:     Tuple=3_072     ,		__SCREAMING_SNAKE_CASE							:     str=2     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=512     ,		__SCREAMING_SNAKE_CASE							:     Any=256     ,		__SCREAMING_SNAKE_CASE							:     int=True     ,		__SCREAMING_SNAKE_CASE							:     Dict=True     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=("p2c", "c2p")     ,		__SCREAMING_SNAKE_CASE							:     str="layer_norm"     ,		__SCREAMING_SNAKE_CASE							:     str="gelu_python"     ,		__SCREAMING_SNAKE_CASE							:     int=0.1     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]=0.1     ,		__SCREAMING_SNAKE_CASE							:     int=0.1     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=0.0     ,		__SCREAMING_SNAKE_CASE							:     Optional[int]=0.1     ,		__SCREAMING_SNAKE_CASE							:     Tuple=0.02     ,		__SCREAMING_SNAKE_CASE							:     int=1E-7     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]=1E-5     ,		__SCREAMING_SNAKE_CASE							:     Any="group"     ,		__SCREAMING_SNAKE_CASE							:     List[str]="gelu"     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)     ,		__SCREAMING_SNAKE_CASE							:     Dict=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)     ,		__SCREAMING_SNAKE_CASE							:     int=False     ,		__SCREAMING_SNAKE_CASE							:     List[str]=128     ,		__SCREAMING_SNAKE_CASE							:     Any=16     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=True     ,		__SCREAMING_SNAKE_CASE							:     str=0.05     ,		__SCREAMING_SNAKE_CASE							:     List[Any]=10     ,		__SCREAMING_SNAKE_CASE							:     List[str]=2     ,		__SCREAMING_SNAKE_CASE							:     Tuple=0.0     ,		__SCREAMING_SNAKE_CASE							:     List[Any]=10     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]=0     ,		__SCREAMING_SNAKE_CASE							:     Any="mean"     ,		__SCREAMING_SNAKE_CASE							:     str=False     ,		__SCREAMING_SNAKE_CASE							:     Tuple=False     ,		__SCREAMING_SNAKE_CASE							:     int=256     ,		__SCREAMING_SNAKE_CASE							:     Tuple=0     ,		__SCREAMING_SNAKE_CASE							:     str=1     ,		__SCREAMING_SNAKE_CASE							:     Union[str, Any]=2     ,		**__SCREAMING_SNAKE_CASE							:     Optional[Any]     ,		):


           '''simple docstring'''

           super().__init__(**__SCREAMING_SNAKE_CASE     ,		pad_token_id=__SCREAMING_SNAKE_CASE     ,		bos_token_id=__SCREAMING_SNAKE_CASE     ,		eos_token_id=__SCREAMING_SNAKE_CASE)
           __a						       =				hidden_size
           __a						       =				feat_extract_norm
           __a						       =				feat_extract_activation
           __a						       =				list(__SCREAMING_SNAKE_CASE)
           __a						       =				list(__SCREAMING_SNAKE_CASE)
           __a						       =				list(__SCREAMING_SNAKE_CASE)
           __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						       =				squeeze_factor
           __a						       =				max_position_embeddings
           __a						       =				position_buckets
           __a						       =				share_att_key
           __a						       =				relative_attention
           __a						       =				norm_rel_ebd
           __a						       =				list(__SCREAMING_SNAKE_CASE)
           __a						       =				hidden_act
           __a						       =				num_attention_heads
           __a						       =				hidden_dropout
           __a						       =				attention_dropout
           __a						       =				activation_dropout
           __a						       =				feat_proj_dropout
           __a						       =				final_dropout
           __a						       =				layer_norm_eps
           __a						       =				feature_layer_norm_eps
           __a						       =				initializer_range
           __a						       =				vocab_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)`,'''
                   F'but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)'
                   F'= {len(self.conv_stride)}`, `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

           # ctc loss
           __a						       =				ctc_loss_reduction
           __a						       =				ctc_zero_infinity

           # sequence classification
           __a						       =				use_weighted_layer_sum
           __a						       =				classifier_proj_size





       @property
       def 		_lowerCamelCase			(		self							:     Optional[int]):


           '''simple docstring'''

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










import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible

class     _A       (	unittest.TestCase    ):



       def 		_lowerCamelCase			(		self							:     List[Any]):


           '''simple docstring'''

           __a						       =				[
               '''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(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''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(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
           ]
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Union[str, Any]):


           '''simple docstring'''

           __a						       =				[
               '''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(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Tuple):


           '''simple docstring'''

           __a						       =				[
               '''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''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.fp16.bin''',
               '''unet/diffusion_pytorch_model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Union[str, Any]):


           '''simple docstring'''

           __a						       =				[
               '''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',
           ]
           __a						       =				'''fp16'''
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.fp16.bin''',
               '''text_encoder/model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))





       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           __a						       =				[
               '''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''',
           ]
           __a						       =				'''fp16'''
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))





