
import functools
import operator

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


__lowerCamelCase							= logging.get_logger(__name__)

__lowerCamelCase							= {
    """facebook/hubert-base-ls960""": """https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json""",
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}






class 						UpperCAmelCase	(		__lowerCamelCase				):
   A__      :	int		  =  'hubert'



   def __init__(self	:      Union[str, Any]					,		snake_case__	:      int=32					,		snake_case__	:      List[Any]=7_68					,		snake_case__	:      int=12					,		snake_case__	:      int=12					,		snake_case__	:      Optional[int]=30_72					,		snake_case__	:      Optional[Any]="gelu"					,		snake_case__	:      Any=0.1					,		snake_case__	:      Union[str, Any]=0.1					,		snake_case__	:      int=0.1					,		snake_case__	:      Union[str, Any]=True					,		snake_case__	:      List[str]=0.0					,		snake_case__	:      Dict=0.1					,		snake_case__	:      Optional[Any]=0.1					,		snake_case__	:      Optional[int]=0.02					,		snake_case__	:      Union[str, Any]=1e-5					,		snake_case__	:      str="group"					,		snake_case__	:      List[Any]="gelu"					,		snake_case__	:      Tuple=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)					,		snake_case__	:      Union[str, Any]=(5, 2, 2, 2, 2, 2, 2)					,		snake_case__	:      List[Any]=(10, 3, 3, 3, 3, 2, 2)					,		snake_case__	:      int=False					,		snake_case__	:      Optional[Any]=1_28					,		snake_case__	:      int=16					,		snake_case__	:      Union[str, Any]=False					,		snake_case__	:      Optional[int]=True					,		snake_case__	:      List[str]=0.05					,		snake_case__	:      Tuple=10					,		snake_case__	:      Tuple=2					,		snake_case__	:      int=0.0					,		snake_case__	:      int=10					,		snake_case__	:      Optional[Any]=0					,		snake_case__	:      Tuple="sum"					,		snake_case__	:      Any=False					,		snake_case__	:      Optional[int]=False					,		snake_case__	:      str=2_56					,		snake_case__	:      Optional[int]=0					,		snake_case__	:      List[Any]=1					,		snake_case__	:      int=2					,		**snake_case__	:      Union[str, Any]					,		)	->			Dict:


          '''simple docstring'''


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

          # ctc loss
          snake_case :     str           =   ctc_loss_reduction
          snake_case :     Any           =   ctc_zero_infinity



   @property
   def        _SCREAMING_SNAKE_CASE     (self	:      Any				)	->			Tuple:


          '''simple docstring'''


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







import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import Mock, patch

import diffusers.utils.hub_utils






class 						UpperCAmelCase	(		unittest.TestCase				):



   @patch("diffusers.utils.hub_utils.get_full_repo_name"				)
   def        _SCREAMING_SNAKE_CASE     (self	:      Any					,		snake_case__	:      Mock				)	->			None:


          '''simple docstring'''


          snake_case :     str           =   "full_repo_name"
          with TemporaryDirectory() as tmpdir:
                 # Dummy args values
                 snake_case :     List[str]           =   Mock()
                 snake_case :     List[str]           =   tmpdir
                 snake_case :     Optional[int]           =   0
                 snake_case :     int           =   "hub_token"
                 snake_case :     Union[str, Any]           =   "dataset_name"
                 snake_case :     Tuple           =   0.01
                 snake_case :     int           =   10_00_00
                 snake_case :     Optional[Any]           =   1_00_00
                 snake_case :     Optional[Any]           =   0.01
                 snake_case :     Dict           =   0.02
                 snake_case :     List[Any]           =   0.03
                 snake_case :     str           =   0.0005
                 snake_case :     List[str]           =   0.000001
                 snake_case :     Tuple           =   1
                 snake_case :     Optional[int]           =   10
                 snake_case :     List[str]           =   0.001
                 snake_case :     List[Any]           =   0.1
                 snake_case :     List[str]           =   0.2
                 snake_case :     Tuple           =   True

                 # Model card mush be rendered and saved
                 diffusers.utils.hub_utils.create_model_card(snake_case__					,		model_name="model_name"				)
                 self.assertTrue((Path(snake_case__				) / "README.md").is_file()				)





