





"""simple docstring"""





import functools
import operator

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


_lowerCamelCase       =	logging.get_logger(__name__)

_lowerCamelCase       =	{
    '''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 			snake_case		(   __UpperCAmelCase   ):
      lowerCamelCase__						= '''hubert'''

      def __init__(			self   :int						,							_lowerCamelCase   :Any=3_2						,							_lowerCamelCase   :List[Any]=7_6_8						,							_lowerCamelCase   :Tuple=1_2						,							_lowerCamelCase   :Optional[int]=1_2						,							_lowerCamelCase   :List[str]=3_0_7_2						,							_lowerCamelCase   :Optional[int]="gelu"						,							_lowerCamelCase   :Union[str, Any]=0.1						,							_lowerCamelCase   :Union[str, Any]=0.1						,							_lowerCamelCase   :List[str]=0.1						,							_lowerCamelCase   :str=True						,							_lowerCamelCase   :str=0.0						,							_lowerCamelCase   :Union[str, Any]=0.1						,							_lowerCamelCase   :Dict=0.1						,							_lowerCamelCase   :Optional[int]=0.0_2						,							_lowerCamelCase   :Any=1e-5						,							_lowerCamelCase   :Optional[int]="group"						,							_lowerCamelCase   :Dict="gelu"						,							_lowerCamelCase   :Any=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)						,							_lowerCamelCase   :Optional[int]=(5, 2, 2, 2, 2, 2, 2)						,							_lowerCamelCase   :int=(1_0, 3, 3, 3, 3, 2, 2)						,							_lowerCamelCase   :str=False						,							_lowerCamelCase   :Dict=1_2_8						,							_lowerCamelCase   :Union[str, Any]=1_6						,							_lowerCamelCase   :str=False						,							_lowerCamelCase   :Union[str, Any]=True						,							_lowerCamelCase   :Optional[Any]=0.0_5						,							_lowerCamelCase   :Any=1_0						,							_lowerCamelCase   :int=2						,							_lowerCamelCase   :Optional[Any]=0.0						,							_lowerCamelCase   :str=1_0						,							_lowerCamelCase   :List[str]=0						,							_lowerCamelCase   :Any="sum"						,							_lowerCamelCase   :Optional[int]=False						,							_lowerCamelCase   :Dict=False						,							_lowerCamelCase   :Any=2_5_6						,							_lowerCamelCase   :Union[str, Any]=0						,							_lowerCamelCase   :Union[str, Any]=1						,							_lowerCamelCase   :str=2						,							**_lowerCamelCase   :Union[str, Any]						,							):
       super().__init__(**_lowerCamelCase						,							pad_token_id=_lowerCamelCase						,							bos_token_id=_lowerCamelCase						,							eos_token_id=_lowerCamelCase						)
       __SCREAMING_SNAKE_CASE :			List[Any]												=       hidden_size
       __SCREAMING_SNAKE_CASE :			Optional[int]												=       feat_extract_norm
       __SCREAMING_SNAKE_CASE :			int												=       feat_extract_activation
       __SCREAMING_SNAKE_CASE :			List[str]												=       list(_lowerCamelCase						)
       __SCREAMING_SNAKE_CASE :			List[Any]												=       list(_lowerCamelCase						)
       __SCREAMING_SNAKE_CASE :			Tuple												=       list(_lowerCamelCase						)
       __SCREAMING_SNAKE_CASE :			Optional[Any]												=       conv_bias
       __SCREAMING_SNAKE_CASE :			List[str]												=       num_conv_pos_embeddings
       __SCREAMING_SNAKE_CASE :			Dict												=       num_conv_pos_embedding_groups
       __SCREAMING_SNAKE_CASE :			Union[str, Any]												=       len(self.conv_dim						)
       __SCREAMING_SNAKE_CASE :			int												=       num_hidden_layers
       __SCREAMING_SNAKE_CASE :			Tuple												=       intermediate_size
       __SCREAMING_SNAKE_CASE :			List[str]												=       hidden_act
       __SCREAMING_SNAKE_CASE :			Union[str, Any]												=       num_attention_heads
       __SCREAMING_SNAKE_CASE :			int												=       hidden_dropout
       __SCREAMING_SNAKE_CASE :			Any												=       attention_dropout
       __SCREAMING_SNAKE_CASE :			Optional[int]												=       activation_dropout
       __SCREAMING_SNAKE_CASE :			Any												=       feat_proj_layer_norm
       __SCREAMING_SNAKE_CASE :			List[str]												=       feat_proj_dropout
       __SCREAMING_SNAKE_CASE :			Tuple												=       final_dropout
       __SCREAMING_SNAKE_CASE :			Any												=       layerdrop
       __SCREAMING_SNAKE_CASE :			Union[str, Any]												=       layer_norm_eps
       __SCREAMING_SNAKE_CASE :			int												=       initializer_range
       __SCREAMING_SNAKE_CASE :			Any												=       vocab_size
       __SCREAMING_SNAKE_CASE :			Tuple												=       do_stable_layer_norm
       __SCREAMING_SNAKE_CASE :			List[Any]												=       use_weighted_layer_sum
       __SCREAMING_SNAKE_CASE :			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 :			Optional[Any]												=       apply_spec_augment
       __SCREAMING_SNAKE_CASE :			str												=       mask_time_prob
       __SCREAMING_SNAKE_CASE :			List[Any]												=       mask_time_length
       __SCREAMING_SNAKE_CASE :			List[Any]												=       mask_time_min_masks
       __SCREAMING_SNAKE_CASE :			str												=       mask_feature_prob
       __SCREAMING_SNAKE_CASE :			Optional[int]												=       mask_feature_length
       __SCREAMING_SNAKE_CASE :			str												=       mask_feature_min_masks

       # ctc loss
       __SCREAMING_SNAKE_CASE :			Optional[int]												=       ctc_loss_reduction
       __SCREAMING_SNAKE_CASE :			Tuple												=       ctc_zero_infinity



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



'''simple docstring'''



from ..utils import deprecate
from .attention_processor import (  # noqa: F401
    Attention,
    AttentionProcessor,
    AttnAddedKVProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRALinearLayer,
    LoRAXFormersAttnProcessor,
    SlicedAttnAddedKVProcessor,
    SlicedAttnProcessor,
    XFormersAttnProcessor,
)
from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401


deprecate(
    "cross_attention",
    "0.20.0",
    "Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.",
    standard_warn=False,
)


UpperCamelCase__					:						str											=     AttentionProcessor

class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	int:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	Any:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	List[str]:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	Tuple:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	str:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	Union[str, Any]:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	str:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






class       _a (_lowerCamelCase):





       """simple docstring"""




       def __init__(							self				,							*A__				,							**A__					)			->	Any:
          _SCREAMING_SNAKE_CASE          = F"{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {''.join(self.__class__.__name__.split('Cross'					)					)} instead."
          deprecate("""cross_attention"""				,							"""0.20.0"""				,							A__				,							standard_warn=A__					)
          super().__init__(*A__				,							**A__					)






