'''simple docstring'''

from typing import TYPE_CHECKING

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


_lowerCamelCase :				Dict														= {
    """configuration_xlm_prophetnet""": ["""XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMProphetNetConfig"""],
}

try:
      if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCamelCase :				Optional[Any]														= ["""XLMProphetNetTokenizer"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCamelCase :				int														= [
          """XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """XLMProphetNetDecoder""",
          """XLMProphetNetEncoder""",
          """XLMProphetNetForCausalLM""",
          """XLMProphetNetForConditionalGeneration""",
          """XLMProphetNetModel""",
          """XLMProphetNetPreTrainedModel""",
      ]


if TYPE_CHECKING:
      from .configuration_xlm_prophetnet import XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMProphetNetConfig

      try:
            if not is_sentencepiece_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_xlm_prophetnet import XLMProphetNetTokenizer

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_xlm_prophetnet import (
                XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST,
                XLMProphetNetDecoder,
                XLMProphetNetEncoder,
                XLMProphetNetForCausalLM,
                XLMProphetNetForConditionalGeneration,
                XLMProphetNetModel,
                XLMProphetNetPreTrainedModel,
            )

else:
      import sys

      _lowerCamelCase :				int														= _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)







"""simple docstring"""





import functools
import operator

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


A__       :			int=						logging.get_logger(__name__)

A__       :			Optional[int]=						{
    """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  __lowerCamelCase     (	_a	):
   a   :					Dict			    ="""hubert"""

   def __init__(       self			,					snake_case_=32			,					snake_case_=768			,					snake_case_=12			,					snake_case_=12			,					snake_case_=3072			,					snake_case_="gelu"			,					snake_case_=0.1			,					snake_case_=0.1			,					snake_case_=0.1			,					snake_case_=True			,					snake_case_=0.0			,					snake_case_=0.1			,					snake_case_=0.1			,					snake_case_=0.02			,					snake_case_=1E-5			,					snake_case_="group"			,					snake_case_="gelu"			,					snake_case_=(512, 512, 512, 512, 512, 512, 512)			,					snake_case_=(5, 2, 2, 2, 2, 2, 2)			,					snake_case_=(10, 3, 3, 3, 3, 2, 2)			,					snake_case_=False			,					snake_case_=128			,					snake_case_=16			,					snake_case_=False			,					snake_case_=True			,					snake_case_=0.05			,					snake_case_=10			,					snake_case_=2			,					snake_case_=0.0			,					snake_case_=10			,					snake_case_=0			,					snake_case_="sum"			,					snake_case_=False			,					snake_case_=False			,					snake_case_=256			,					snake_case_=0			,					snake_case_=1			,					snake_case_=2			,					**snake_case_			,					)		->							Any:
       super().__init__(**snake_case_			,					pad_token_id=snake_case_			,					bos_token_id=snake_case_			,					eos_token_id=snake_case_   )
       UpperCamelCase__								=     hidden_size
       UpperCamelCase__								=     feat_extract_norm
       UpperCamelCase__								=     feat_extract_activation
       UpperCamelCase__								=     list(snake_case_   )
       UpperCamelCase__								=     list(snake_case_   )
       UpperCamelCase__								=     list(snake_case_   )
       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     SCREAMING_SNAKE_CASE__			(       self   )		->							Dict:
       return functools.reduce(operator.mul			,					self.conv_stride			,					1   )




