

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 						a_			(				_UpperCamelCase	):



      """simple docstring"""







      __UpperCAmelCase     						= 'hubert'
      def __init__( self	:				str     ,snake_case	:				str=32     ,snake_case	:				Any=768     ,snake_case	:				Optional[int]=12     ,snake_case	:				Optional[Any]=12     ,snake_case	:				Tuple=3072     ,snake_case	:				Any="gelu"     ,snake_case	:				List[str]=0.1     ,snake_case	:				Optional[int]=0.1     ,snake_case	:				Union[str, Any]=0.1     ,snake_case	:				Optional[int]=True     ,snake_case	:				List[Any]=0.0     ,snake_case	:				int=0.1     ,snake_case	:				Union[str, Any]=0.1     ,snake_case	:				str=0.02     ,snake_case	:				List[Any]=1e-5     ,snake_case	:				Optional[Any]="group"     ,snake_case	:				List[str]="gelu"     ,snake_case	:				int=(512, 512, 512, 512, 512, 512, 512)     ,snake_case	:				Dict=(5, 2, 2, 2, 2, 2, 2)     ,snake_case	:				int=(10, 3, 3, 3, 3, 2, 2)     ,snake_case	:				int=False     ,snake_case	:				Dict=128     ,snake_case	:				int=16     ,snake_case	:				List[Any]=False     ,snake_case	:				int=True     ,snake_case	:				Dict=0.05     ,snake_case	:				Union[str, Any]=10     ,snake_case	:				Optional[Any]=2     ,snake_case	:				Dict=0.0     ,snake_case	:				List[Any]=10     ,snake_case	:				Dict=0     ,snake_case	:				List[str]="sum"     ,snake_case	:				Optional[Any]=False     ,snake_case	:				Union[str, Any]=False     ,snake_case	:				Tuple=256     ,snake_case	:				Optional[int]=0     ,snake_case	:				Union[str, Any]=1     ,snake_case	:				Union[str, Any]=2     ,**snake_case	:				Optional[int]     ,):
           super().__init__(**a__     ,pad_token_id=a__     ,bos_token_id=a__     ,eos_token_id=a__							)
           SCREAMING_SNAKE_CASE 		=hidden_size
           SCREAMING_SNAKE_CASE 		=feat_extract_norm
           SCREAMING_SNAKE_CASE 		=feat_extract_activation
           SCREAMING_SNAKE_CASE 		=list(a__							)
           SCREAMING_SNAKE_CASE 		=list(a__							)
           SCREAMING_SNAKE_CASE 		=list(a__							)
           SCREAMING_SNAKE_CASE 		=conv_bias
           SCREAMING_SNAKE_CASE 		=num_conv_pos_embeddings
           SCREAMING_SNAKE_CASE 		=num_conv_pos_embedding_groups
           SCREAMING_SNAKE_CASE 		=len(self.conv_dim							)
           SCREAMING_SNAKE_CASE 		=num_hidden_layers
           SCREAMING_SNAKE_CASE 		=intermediate_size
           SCREAMING_SNAKE_CASE 		=hidden_act
           SCREAMING_SNAKE_CASE 		=num_attention_heads
           SCREAMING_SNAKE_CASE 		=hidden_dropout
           SCREAMING_SNAKE_CASE 		=attention_dropout
           SCREAMING_SNAKE_CASE 		=activation_dropout
           SCREAMING_SNAKE_CASE 		=feat_proj_layer_norm
           SCREAMING_SNAKE_CASE 		=feat_proj_dropout
           SCREAMING_SNAKE_CASE 		=final_dropout
           SCREAMING_SNAKE_CASE 		=layerdrop
           SCREAMING_SNAKE_CASE 		=layer_norm_eps
           SCREAMING_SNAKE_CASE 		=initializer_range
           SCREAMING_SNAKE_CASE 		=vocab_size
           SCREAMING_SNAKE_CASE 		=do_stable_layer_norm
           SCREAMING_SNAKE_CASE 		=use_weighted_layer_sum
           SCREAMING_SNAKE_CASE 		=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
           SCREAMING_SNAKE_CASE 		=apply_spec_augment
           SCREAMING_SNAKE_CASE 		=mask_time_prob
           SCREAMING_SNAKE_CASE 		=mask_time_length
           SCREAMING_SNAKE_CASE 		=mask_time_min_masks
           SCREAMING_SNAKE_CASE 		=mask_feature_prob
           SCREAMING_SNAKE_CASE 		=mask_feature_length
           SCREAMING_SNAKE_CASE 		=mask_feature_min_masks

           # ctc loss
           SCREAMING_SNAKE_CASE 		=ctc_loss_reduction
           SCREAMING_SNAKE_CASE 		=ctc_zero_infinity


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





"""simple docstring"""


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

import diffusers.utils.hub_utils
class snake_case   (	unittest.TestCase):







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





						'''simple docstring'''







						_A       	=      "full_repo_name"
						with TemporaryDirectory() as tmpdir:
										# Dummy args values
										_A       	=      Mock()
										_A       	=      tmpdir
										_A       	=      0
										_A       	=      "hub_token"
										_A       	=      "dataset_name"
										_A       	=      0.0_1
										_A       	=      10_00_00
										_A       	=      1_00_00
										_A       	=      0.0_1
										_A       	=      0.0_2
										_A       	=      0.0_3
										_A       	=      0.0_0_0_5
										_A       	=      0.0_0_0_0_0_1
										_A       	=      1
										_A       	=      10
										_A       	=      0.0_0_1
										_A       	=      0.1
										_A       	=      0.2
										_A       	=      True

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