"""simple docstring"""


import functools
import operator

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


UpperCAmelCase__     						=  logging.get_logger(__name__)

UpperCAmelCase__     						=  {
    """facebook/wav2vec2-base-960h""": """https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json""",
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}


class 				a (						lowerCAmelCase_      ):
    _snake_case   :     Optional[int]   							=							'wav2vec2'


    def __init__(    self		:     Tuple      , __lowerCAmelCase		:     List[Any]=32      , __lowerCAmelCase		:     Tuple=768      , __lowerCAmelCase		:     Optional[int]=12      , __lowerCAmelCase		:     Any=12      , __lowerCAmelCase		:     Any=3072      , __lowerCAmelCase		:     Any="gelu"      , __lowerCAmelCase		:     int=0.1      , __lowerCAmelCase		:     List[Any]=0.1      , __lowerCAmelCase		:     Optional[Any]=0.1      , __lowerCAmelCase		:     Dict=0.0      , __lowerCAmelCase		:     Tuple=0.0      , __lowerCAmelCase		:     int=0.1      , __lowerCAmelCase		:     Optional[int]=0.1      , __lowerCAmelCase		:     Any=0.02      , __lowerCAmelCase		:     Optional[Any]=1e-5      , __lowerCAmelCase		:     Tuple="group"      , __lowerCAmelCase		:     str="gelu"      , __lowerCAmelCase		:     List[str]=(512, 512, 512, 512, 512, 512, 512)      , __lowerCAmelCase		:     Optional[int]=(5, 2, 2, 2, 2, 2, 2)      , __lowerCAmelCase		:     Dict=(10, 3, 3, 3, 3, 2, 2)      , __lowerCAmelCase		:     Dict=False      , __lowerCAmelCase		:     List[str]=128      , __lowerCAmelCase		:     List[Any]=16      , __lowerCAmelCase		:     Any=False      , __lowerCAmelCase		:     str=True      , __lowerCAmelCase		:     List[str]=0.05      , __lowerCAmelCase		:     str=10      , __lowerCAmelCase		:     str=2      , __lowerCAmelCase		:     Any=0.0      , __lowerCAmelCase		:     Optional[int]=10      , __lowerCAmelCase		:     List[Any]=0      , __lowerCAmelCase		:     Optional[Any]=320      , __lowerCAmelCase		:     int=2      , __lowerCAmelCase		:     List[Any]=0.1      , __lowerCAmelCase		:     Optional[Any]=100      , __lowerCAmelCase		:     Optional[Any]=256      , __lowerCAmelCase		:     List[str]=256      , __lowerCAmelCase		:     Any=0.1      , __lowerCAmelCase		:     Optional[int]="sum"      , __lowerCAmelCase		:     Union[str, Any]=False      , __lowerCAmelCase		:     List[str]=False      , __lowerCAmelCase		:     Dict=256      , __lowerCAmelCase		:     int=(512, 512, 512, 512, 1500)      , __lowerCAmelCase		:     Optional[int]=(5, 3, 3, 1, 1)      , __lowerCAmelCase		:     List[str]=(1, 2, 3, 1, 1)      , __lowerCAmelCase		:     Union[str, Any]=512      , __lowerCAmelCase		:     Dict=0      , __lowerCAmelCase		:     List[str]=1      , __lowerCAmelCase		:     Optional[int]=2      , __lowerCAmelCase		:     Union[str, Any]=False      , __lowerCAmelCase		:     Any=3      , __lowerCAmelCase		:     Optional[int]=2      , __lowerCAmelCase		:     Tuple=3      , __lowerCAmelCase		:     Union[str, Any]=None      , __lowerCAmelCase		:     Tuple=None      , **__lowerCAmelCase		:     Dict      , ):
      super().__init__(**__lowerCAmelCase      , pad_token_id=__lowerCAmelCase      , bos_token_id=__lowerCAmelCase      , eos_token_id=__lowerCAmelCase    )
      _UpperCAmelCase         =					hidden_size
      _UpperCAmelCase         =					feat_extract_norm
      _UpperCAmelCase         =					feat_extract_activation
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _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_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

      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

      # parameters for pretraining with codevector quantized representations
      _UpperCAmelCase         =					num_codevectors_per_group
      _UpperCAmelCase         =					num_codevector_groups
      _UpperCAmelCase         =					contrastive_logits_temperature
      _UpperCAmelCase         =					feat_quantizer_dropout
      _UpperCAmelCase         =					num_negatives
      _UpperCAmelCase         =					codevector_dim
      _UpperCAmelCase         =					proj_codevector_dim
      _UpperCAmelCase         =					diversity_loss_weight

      # ctc loss
      _UpperCAmelCase         =					ctc_loss_reduction
      _UpperCAmelCase         =					ctc_zero_infinity

      # adapter
      _UpperCAmelCase         =					add_adapter
      _UpperCAmelCase         =					adapter_kernel_size
      _UpperCAmelCase         =					adapter_stride
      _UpperCAmelCase         =					num_adapter_layers
      _UpperCAmelCase         =					output_hidden_size or hidden_size
      _UpperCAmelCase         =					adapter_attn_dim

      # SequenceClassification-specific parameter. Feel free to ignore for other classes.
      _UpperCAmelCase         =					classifier_proj_size

      # XVector-specific parameters. Feel free to ignore for other classes.
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _UpperCAmelCase         =					list(__lowerCAmelCase    )
      _UpperCAmelCase         =					xvector_output_dim


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

"""simple docstring"""


from __future__ import annotations






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					get_failure_array(lowercase						)

  # 2) Step through text searching for pattern
  _UpperCAmelCase       , _UpperCAmelCase         =					0, 0  # index into text, pattern
  while i < len(lowercase						):
    if pattern[j] == text[i]:
      if j == (len(lowercase						) - 1):
        return True
      j += 1

    # if this is a prefix in our pattern
    # just go back far enough to continue
    elif j > 0:
      _UpperCAmelCase         =					failure[j - 1]
      continue
    i += 1
  return False






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					[0]
  _UpperCAmelCase         =					0
  _UpperCAmelCase         =					1
  while j < len(lowercase						):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      _UpperCAmelCase         =					failure[i - 1]
      continue
    j += 1
    failure.append(lowercase						)
  return failure


if __name__ == "__main__":
    # Test 1)
    UpperCAmelCase__     						=  """abc1abc12"""
    UpperCAmelCase__     						=  """alskfjaldsabc1abc1abc12k23adsfabcabc"""
    UpperCAmelCase__     						=  """alskfjaldsk23adsfabcabc"""
    assert kmp(pattern, texta) and not kmp(pattern, texta)

    # Test 2)
    UpperCAmelCase__     						=  """ABABX"""
    UpperCAmelCase__     						=  """ABABZABABYABABX"""
    assert kmp(pattern, text)

    # Test 3)
    UpperCAmelCase__     						=  """AAAB"""
    UpperCAmelCase__     						=  """ABAAAAAB"""
    assert kmp(pattern, text)

    # Test 4)
    UpperCAmelCase__     						=  """abcdabcy"""
    UpperCAmelCase__     						=  """abcxabcdabxabcdabcdabcy"""
    assert kmp(pattern, text)

    # Test 5)
    UpperCAmelCase__     						=  """aabaabaaa"""
    assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]
