

import functools
import operator

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


UpperCAmelCase__			:  List[str]					     =     logging.get_logger(__name__)

UpperCAmelCase__			:  List[Any]					     =     {
    """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__   :			Tuple      							="""hubert"""


  def __init__(      self     :			Any					,					UpperCAmelCase__     :			Optional[int]=3_2					,					UpperCAmelCase__     :			List[str]=7_6_8					,					UpperCAmelCase__     :			Tuple=1_2					,					UpperCAmelCase__     :			Dict=1_2					,					UpperCAmelCase__     :			Dict=3_0_7_2					,					UpperCAmelCase__     :			str="gelu"					,					UpperCAmelCase__     :			Optional[Any]=0.1					,					UpperCAmelCase__     :			Union[str, Any]=0.1					,					UpperCAmelCase__     :			Tuple=0.1					,					UpperCAmelCase__     :			Optional[int]=True					,					UpperCAmelCase__     :			Any=0.0					,					UpperCAmelCase__     :			Union[str, Any]=0.1					,					UpperCAmelCase__     :			Tuple=0.1					,					UpperCAmelCase__     :			Optional[Any]=0.02					,					UpperCAmelCase__     :			Union[str, Any]=1e-5					,					UpperCAmelCase__     :			List[Any]="group"					,					UpperCAmelCase__     :			List[Any]="gelu"					,					UpperCAmelCase__     :			Union[str, Any]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)					,					UpperCAmelCase__     :			Tuple=(5, 2, 2, 2, 2, 2, 2)					,					UpperCAmelCase__     :			Optional[Any]=(1_0, 3, 3, 3, 3, 2, 2)					,					UpperCAmelCase__     :			List[str]=False					,					UpperCAmelCase__     :			str=1_2_8					,					UpperCAmelCase__     :			List[Any]=1_6					,					UpperCAmelCase__     :			Tuple=False					,					UpperCAmelCase__     :			Tuple=True					,					UpperCAmelCase__     :			int=0.05					,					UpperCAmelCase__     :			Tuple=1_0					,					UpperCAmelCase__     :			List[str]=2					,					UpperCAmelCase__     :			Optional[int]=0.0					,					UpperCAmelCase__     :			Any=1_0					,					UpperCAmelCase__     :			Any=0					,					UpperCAmelCase__     :			Tuple="sum"					,					UpperCAmelCase__     :			List[str]=False					,					UpperCAmelCase__     :			Dict=False					,					UpperCAmelCase__     :			Optional[Any]=2_5_6					,					UpperCAmelCase__     :			List[Any]=0					,					UpperCAmelCase__     :			Dict=1					,					UpperCAmelCase__     :			List[Any]=2					,					**UpperCAmelCase__     :			Dict					,					)       ->Dict:
        """simple docstring"""







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

        # ctc loss
        SCREAMING_SNAKE_CASE			:   Optional[int]	  = ctc_loss_reduction
        SCREAMING_SNAKE_CASE			:   Any	  = ctc_zero_infinity




  @property
  def 			_lowercase   (      self     :			Any		)       ->Optional[Any]:
        """simple docstring"""







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







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


UpperCAmelCase__			:  Dict					     =     {"""configuration_hubert""": ["""HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """HubertConfig"""]}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  Union[str, Any]					     =     [
      """HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """HubertForCTC""",
      """HubertForSequenceClassification""",
      """HubertModel""",
      """HubertPreTrainedModel""",
  ]


try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  List[Any]					     =     [
      """TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TFHubertForCTC""",
      """TFHubertModel""",
      """TFHubertPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_hubert import (
        HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        HubertForCTC,
        HubertForSequenceClassification,
        HubertModel,
        HubertPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_hubert import (
        TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFHubertForCTC,
        TFHubertModel,
        TFHubertPreTrainedModel,
    )


else:
  import sys

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




