



import functools
import operator

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


_snake_case		=  logging.get_logger(__name__)

_snake_case		=  {
    "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json",
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}



class   UpperCAmelCase_    (       a):
							lowerCamelCase__   			=		'sew-d'







							def __init__(   self,			__a=32,			__a=768,			__a=12,			__a=12,			__a=3072,			__a=2,			__a=512,			__a=256,			__a=True,			__a=True,			__a=("p2c", "c2p"),			__a="layer_norm",			__a="gelu_python",			__a=0.1,			__a=0.1,			__a=0.1,			__a=0.0,			__a=0.1,			__a=0.02,			__a=1E-7,			__a=1E-5,			__a="group",			__a="gelu",			__a=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512),			__a=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1),			__a=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1),			__a=False,			__a=128,			__a=16,			__a=True,			__a=0.05,			__a=10,			__a=2,			__a=0.0,			__a=10,			__a=0,			__a="mean",			__a=False,			__a=False,			__a=256,			__a=0,			__a=1,			__a=2,			**__a,			):

														'''simple docstring'''

														super().__init__(**__a,			pad_token_id=__a,			bos_token_id=__a,			eos_token_id=__a)
														_lowerCAmelCase     :							Tuple    =    hidden_size
														_lowerCAmelCase     :							List[Any]    =    feat_extract_norm
														_lowerCAmelCase     :							Dict    =    feat_extract_activation
														_lowerCAmelCase     :							Dict    =    list(__a)
														_lowerCAmelCase     :							Dict    =    list(__a)
														_lowerCAmelCase     :							List[str]    =    list(__a)
														_lowerCAmelCase     :							Dict    =    conv_bias
														_lowerCAmelCase     :							str    =    num_conv_pos_embeddings
														_lowerCAmelCase     :							int    =    num_conv_pos_embedding_groups
														_lowerCAmelCase     :							Dict    =    len(self.conv_dim)
														_lowerCAmelCase     :							List[str]    =    num_hidden_layers
														_lowerCAmelCase     :							List[Any]    =    intermediate_size
														_lowerCAmelCase     :							Dict    =    squeeze_factor
														_lowerCAmelCase     :							Any    =    max_position_embeddings
														_lowerCAmelCase     :							Optional[Any]    =    position_buckets
														_lowerCAmelCase     :							Optional[int]    =    share_att_key
														_lowerCAmelCase     :							str    =    relative_attention
														_lowerCAmelCase     :							Dict    =    norm_rel_ebd
														_lowerCAmelCase     :							Optional[int]    =    list(__a)
														_lowerCAmelCase     :							List[str]    =    hidden_act
														_lowerCAmelCase     :							Union[str, Any]    =    num_attention_heads
														_lowerCAmelCase     :							Optional[Any]    =    hidden_dropout
														_lowerCAmelCase     :							Dict    =    attention_dropout
														_lowerCAmelCase     :							str    =    activation_dropout
														_lowerCAmelCase     :							Optional[Any]    =    feat_proj_dropout
														_lowerCAmelCase     :							Tuple    =    final_dropout
														_lowerCAmelCase     :							Dict    =    layer_norm_eps
														_lowerCAmelCase     :							Union[str, Any]    =    feature_layer_norm_eps
														_lowerCAmelCase     :							str    =    initializer_range
														_lowerCAmelCase     :							str    =    vocab_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)`,"
																					    f"but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)"
																					    f"= {len(self.conv_stride)}`, `len(config.conv_kernel) = {len(self.conv_kernel)}`.")

														# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
														_lowerCAmelCase     :							List[Any]    =    apply_spec_augment
														_lowerCAmelCase     :							Optional[int]    =    mask_time_prob
														_lowerCAmelCase     :							Any    =    mask_time_length
														_lowerCAmelCase     :							Tuple    =    mask_time_min_masks
														_lowerCAmelCase     :							List[str]    =    mask_feature_prob
														_lowerCAmelCase     :							List[str]    =    mask_feature_length
														_lowerCAmelCase     :							Tuple    =    mask_feature_min_masks

														# ctc loss
														_lowerCAmelCase     :							Optional[Any]    =    ctc_loss_reduction
														_lowerCAmelCase     :							List[str]    =    ctc_zero_infinity

														# sequence classification
														_lowerCAmelCase     :							Optional[int]    =    use_weighted_layer_sum
														_lowerCAmelCase     :							Union[str, Any]    =    classifier_proj_size







							@property
							def    snake_case__      (   self):

														'''simple docstring'''

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







"""simple docstring"""




from copy import deepcopy

class  _UpperCAmelCase  :



      '''simple docstring'''

      def __init__(     self					,      snake_case_ = None					,      snake_case_ = None  ):

        """simple docstring"""

        if arr is None and size is not None:
          A_  :       Union[str, Any]										=  size
          A_  :       List[str]										=  [0] * size
        elif arr is not None:
          self.init(snake_case_  )
        else:
          raise ValueError('Either arr or size must be specified'  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        A_  :       Union[str, Any]										=  len(snake_case_  )
        A_  :       Optional[int]										=  deepcopy(snake_case_  )
        for i in range(1					,      self.size  ):
          A_  :       Optional[Any]										=  self.next_(snake_case_  )
          if j < self.size:
            self.tree[j] += self.tree[i]

      def 					lowerCamelCase_			(     self  ):

        """simple docstring"""

        A_  :       int										=  self.tree[:]
        for i in range(self.size - 1					,      0					,      -1  ):
          A_  :       Optional[int]										=  self.next_(snake_case_  )
          if j < self.size:
            arr[j] -= arr[i]
        return arr

      @staticmethod
      def 					lowerCamelCase_			(     snake_case_  ):

        """simple docstring"""

        return index + (index & (-index))

      @staticmethod
      def 					lowerCamelCase_			(     snake_case_  ):

        """simple docstring"""

        return index - (index & (-index))

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        if index == 0:
          self.tree[0] += value
          return
        while index < self.size:
          self.tree[index] += value
          A_  :       List[str]										=  self.next_(snake_case_  )

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        self.add(snake_case_					,      value - self.get(snake_case_  )  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        if right == 0:
          return 0
        A_  :       Any										=  self.tree[0]
        right -= 1  # make right inclusive
        while right > 0:
          result += self.tree[right]
          A_  :       Tuple										=  self.prev(snake_case_  )
        return result

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        return self.prefix(snake_case_  ) - self.prefix(snake_case_  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        return self.query(snake_case_					,      index + 1  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        value -= self.tree[0]
        if value < 0:
          return -1

        A_  :       List[Any]										=  1  # Largest power of 2 <= size
        while j * 2 < self.size:
          j *= 2

        A_  :       Tuple										=  0

        while j > 0:
          if i + j < self.size and self.tree[i + j] <= value:
            value -= self.tree[i + j]
            i += j
          j //= 2
        return i


if __name__ == "__main__":
   import doctest

   doctest.testmod()