

import functools
import operator

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


SCREAMING_SNAKE_CASE						:Tuple      =			logging.get_logger(__name__)

SCREAMING_SNAKE_CASE						:Dict      =			{
    """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 		__magic_name__ (				snake_case							):
     UpperCamelCase_     :str									=	"""hubert"""






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

         # ctc loss
         UpperCamelCase_          =		ctc_loss_reduction
         UpperCamelCase_          =		ctc_zero_infinity






     @property
     def      UpperCAmelCase_							(							self     )->			Optional[int]:
         return functools.reduce(operator.mul						,		self.conv_stride						,		1     )







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase__  :	Optional[Any]     ={'''configuration_pegasus''': ['''PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusConfig''']}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	Union[str, Any]     =['''PegasusTokenizer''']

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	int     =['''PegasusTokenizerFast''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	str     =[
							    '''PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''PegasusForCausalLM''',
							    '''PegasusForConditionalGeneration''',
							    '''PegasusModel''',
							    '''PegasusPreTrainedModel''',
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	Union[str, Any]     =[
							    '''TFPegasusForConditionalGeneration''',
							    '''TFPegasusModel''',
							    '''TFPegasusPreTrainedModel''',
							]

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	Dict     =[
							    '''FlaxPegasusForConditionalGeneration''',
							    '''FlaxPegasusModel''',
							    '''FlaxPegasusPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_pegasus import PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_pegasus import PegasusTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_pegasus_fast import PegasusTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_pegasus import (
														    PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
														    PegasusForCausalLM,
														    PegasusForConditionalGeneration,
														    PegasusModel,
														    PegasusPreTrainedModel,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_pegasus import TFPegasusForConditionalGeneration, TFPegasusModel, TFPegasusPreTrainedModel

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_pegasus import (
														    FlaxPegasusForConditionalGeneration,
														    FlaxPegasusModel,
														    FlaxPegasusPreTrainedModel,
														)

else:
							import sys

							UpperCAmelCase__  :	Union[str, Any]     =_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





