






"""simple docstring"""




import functools
import operator

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


__snake_case							 =  logging.get_logger(__name__)

__snake_case							 =  {
    """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       UpperCAmelCase_						( lowercase			):



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

          # ctc loss
          UpperCamelCase	:int     							=       ctc_loss_reduction
          UpperCamelCase	:List[Any]     							=       ctc_zero_infinity




      @property
      def    UpperCAmelCase						(    self			)    ->				List[str]:
          return functools.reduce(operator.mul   ,    self.conv_stride   ,    1			)













def   _A       (    SCREAMING_SNAKE_CASE__  :     float					,  SCREAMING_SNAKE_CASE__  :     float					,  SCREAMING_SNAKE_CASE__  :     float	):
    if hue < 0 or hue > 360:
        raise Exception('''hue should be between 0 and 360'''	)

    if saturation < 0 or saturation > 1:
        raise Exception('''saturation should be between 0 and 1'''	)

    if value < 0 or value > 1:
        raise Exception('''value should be between 0 and 1'''	)

    UpperCamelCase	:Tuple     							=       value * saturation
    UpperCamelCase	:Any     							=       hue / 60
    UpperCamelCase	:Any     							=       chroma * (1 - abs(hue_section % 2 - 1	))
    UpperCamelCase	:Optional[int]     							=       value - chroma

    if hue_section >= 0 and hue_section <= 1:
        UpperCamelCase	:Any     							=       round(255 * (chroma + match_value)	)
        UpperCamelCase	:Union[str, Any]     							=       round(255 * (second_largest_component + match_value)	)
        UpperCamelCase	:List[str]     							=       round(255 * (match_value)	)
    elif hue_section > 1 and hue_section <= 2:
        UpperCamelCase	:Dict     							=       round(255 * (second_largest_component + match_value)	)
        UpperCamelCase	:Dict     							=       round(255 * (chroma + match_value)	)
        UpperCamelCase	:str     							=       round(255 * (match_value)	)
    elif hue_section > 2 and hue_section <= 3:
        UpperCamelCase	:Any     							=       round(255 * (match_value)	)
        UpperCamelCase	:Optional[Any]     							=       round(255 * (chroma + match_value)	)
        UpperCamelCase	:Union[str, Any]     							=       round(255 * (second_largest_component + match_value)	)
    elif hue_section > 3 and hue_section <= 4:
        UpperCamelCase	:Tuple     							=       round(255 * (match_value)	)
        UpperCamelCase	:Optional[Any]     							=       round(255 * (second_largest_component + match_value)	)
        UpperCamelCase	:str     							=       round(255 * (chroma + match_value)	)
    elif hue_section > 4 and hue_section <= 5:
        UpperCamelCase	:int     							=       round(255 * (second_largest_component + match_value)	)
        UpperCamelCase	:str     							=       round(255 * (match_value)	)
        UpperCamelCase	:List[str]     							=       round(255 * (chroma + match_value)	)
    else:
        UpperCamelCase	:Union[str, Any]     							=       round(255 * (chroma + match_value)	)
        UpperCamelCase	:List[str]     							=       round(255 * (match_value)	)
        UpperCamelCase	:Optional[int]     							=       round(255 * (second_largest_component + match_value)	)

    return [red, green, blue]


def   _A       (    SCREAMING_SNAKE_CASE__  :     int					,  SCREAMING_SNAKE_CASE__  :     int					,  SCREAMING_SNAKE_CASE__  :     int	):
    if red < 0 or red > 255:
        raise Exception('''red should be between 0 and 255'''	)

    if green < 0 or green > 255:
        raise Exception('''green should be between 0 and 255'''	)

    if blue < 0 or blue > 255:
        raise Exception('''blue should be between 0 and 255'''	)

    UpperCamelCase	:str     							=       red / 255
    UpperCamelCase	:List[str]     							=       green / 255
    UpperCamelCase	:int     							=       blue / 255
    UpperCamelCase	:Optional[int]     							=       max(SCREAMING_SNAKE_CASE__					,  SCREAMING_SNAKE_CASE__					,  SCREAMING_SNAKE_CASE__	)
    UpperCamelCase	:int     							=       value - min(SCREAMING_SNAKE_CASE__					,  SCREAMING_SNAKE_CASE__					,  SCREAMING_SNAKE_CASE__	)
    UpperCamelCase	:Dict     							=       0 if value == 0 else chroma / value

    if chroma == 0:
        UpperCamelCase	:Dict     							=       0.0
    elif value == float_red:
        UpperCamelCase	:Optional[Any]     							=       60 * (0 + (float_green - float_blue) / chroma)
    elif value == float_green:
        UpperCamelCase	:List[str]     							=       60 * (2 + (float_blue - float_red) / chroma)
    else:
        UpperCamelCase	:str     							=       60 * (4 + (float_red - float_green) / chroma)

    UpperCamelCase	:int     							=       (hue + 360) % 360

    return [hue, saturation, value]



def   _A       (    SCREAMING_SNAKE_CASE__  :     list[float]					,  SCREAMING_SNAKE_CASE__  :     list[float]	):
    UpperCamelCase	:str     							=       abs(hsv_a[0] - hsv_a[0]	) < 0.2
    UpperCamelCase	:List[str]     							=       abs(hsv_a[1] - hsv_a[1]	) < 0.0_02
    UpperCamelCase	:Any     							=       abs(hsv_a[2] - hsv_a[2]	) < 0.0_02

    return check_hue and check_saturation and check_value





