






"""simple docstring"""


import functools
import operator

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


UpperCAmelCase__  		=						logging.get_logger(__name__)

UpperCAmelCase__  		=						{
    """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""",
    # See all WavLM models at https://huggingface.co/models?filter=wavlm
}


class        a				(		__A   ):
    _snake_case     :  List[str]     							=							'wavlm'


    def __init__(					self	:  List[Any]   ,				__lowerCAmelCase	:  List[Any]=32   ,				__lowerCAmelCase	:  Any=768   ,				__lowerCAmelCase	:  Optional[int]=12   ,				__lowerCAmelCase	:  Optional[Any]=12   ,				__lowerCAmelCase	:  List[str]=3072   ,				__lowerCAmelCase	:  Optional[Any]="gelu"   ,				__lowerCAmelCase	:  Union[str, Any]=0.1   ,				__lowerCAmelCase	:  Tuple=0.1   ,				__lowerCAmelCase	:  Dict=0.1   ,				__lowerCAmelCase	:  str=0.0   ,				__lowerCAmelCase	:  List[Any]=0.1   ,				__lowerCAmelCase	:  Dict=0.1   ,				__lowerCAmelCase	:  Union[str, Any]=0.02   ,				__lowerCAmelCase	:  str=1e-5   ,				__lowerCAmelCase	:  Dict="group"   ,				__lowerCAmelCase	:  Union[str, Any]="gelu"   ,				__lowerCAmelCase	:  Dict=(512, 512, 512, 512, 512, 512, 512)   ,				__lowerCAmelCase	:  Tuple=(5, 2, 2, 2, 2, 2, 2)   ,				__lowerCAmelCase	:  Union[str, Any]=(10, 3, 3, 3, 3, 2, 2)   ,				__lowerCAmelCase	:  Any=False   ,				__lowerCAmelCase	:  Dict=128   ,				__lowerCAmelCase	:  int=16   ,				__lowerCAmelCase	:  int=320   ,				__lowerCAmelCase	:  Union[str, Any]=800   ,				__lowerCAmelCase	:  List[str]=False   ,				__lowerCAmelCase	:  Dict=True   ,				__lowerCAmelCase	:  Union[str, Any]=0.05   ,				__lowerCAmelCase	:  Optional[int]=10   ,				__lowerCAmelCase	:  Optional[int]=2   ,				__lowerCAmelCase	:  str=0.0   ,				__lowerCAmelCase	:  Tuple=10   ,				__lowerCAmelCase	:  str=320   ,				__lowerCAmelCase	:  List[str]=2   ,				__lowerCAmelCase	:  List[str]=0.1   ,				__lowerCAmelCase	:  List[str]=100   ,				__lowerCAmelCase	:  str=256   ,				__lowerCAmelCase	:  Union[str, Any]=256   ,				__lowerCAmelCase	:  Any=0.1   ,				__lowerCAmelCase	:  Optional[Any]="mean"   ,				__lowerCAmelCase	:  Optional[Any]=False   ,				__lowerCAmelCase	:  int=False   ,				__lowerCAmelCase	:  List[str]=256   ,				__lowerCAmelCase	:  int=(512, 512, 512, 512, 1500)   ,				__lowerCAmelCase	:  Dict=(5, 3, 3, 1, 1)   ,				__lowerCAmelCase	:  Dict=(1, 2, 3, 1, 1)   ,				__lowerCAmelCase	:  Any=512   ,				__lowerCAmelCase	:  List[str]=80   ,				__lowerCAmelCase	:  Any=0   ,				__lowerCAmelCase	:  Tuple=1   ,				__lowerCAmelCase	:  Optional[Any]=2   ,				__lowerCAmelCase	:  Dict=False   ,				__lowerCAmelCase	:  str=3   ,				__lowerCAmelCase	:  Tuple=2   ,				__lowerCAmelCase	:  List[Any]=3   ,				__lowerCAmelCase	:  Tuple=None   ,				**__lowerCAmelCase	:  Tuple   ,				):
      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_buckets
      _UpperCAmelCase						 =      max_bucket_distance
      _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						 =      num_ctc_classes
      _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

      # parameters for pretraining with codevector quantized representations
      _UpperCAmelCase						 =      num_codevectors_per_group
      _UpperCAmelCase						 =      num_codevector_groups
      _UpperCAmelCase						 =      contrastive_logits_temperature
      _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

      # 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	:  Tuple					):
      return functools.reduce(operator.mul   ,				self.conv_stride   ,				1					)

"""simple docstring"""


from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


UpperCAmelCase__  		=						logging.get_logger(__name__)

UpperCAmelCase__  		=						{
    """shi-labs/nat-mini-in1k-224""": """https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json""",
    # See all Nat models at https://huggingface.co/models?filter=nat
}


class        a				(		lowerCAmelCase_	,							lowerCAmelCase_   ):
    _snake_case     :  Union[str, Any]     							=							'nat'

    _snake_case     :  List[str]     							=							{
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }


    def __init__(					self	:  List[Any]   ,				__lowerCAmelCase	:  int=4   ,				__lowerCAmelCase	:  Union[str, Any]=3   ,				__lowerCAmelCase	:  Dict=64   ,				__lowerCAmelCase	:  int=[3, 4, 6, 5]   ,				__lowerCAmelCase	:  List[str]=[2, 4, 8, 16]   ,				__lowerCAmelCase	:  Tuple=7   ,				__lowerCAmelCase	:  List[str]=3.0   ,				__lowerCAmelCase	:  int=True   ,				__lowerCAmelCase	:  int=0.0   ,				__lowerCAmelCase	:  Tuple=0.0   ,				__lowerCAmelCase	:  Any=0.1   ,				__lowerCAmelCase	:  List[str]="gelu"   ,				__lowerCAmelCase	:  List[Any]=0.02   ,				__lowerCAmelCase	:  Union[str, Any]=1e-5   ,				__lowerCAmelCase	:  List[Any]=0.0   ,				__lowerCAmelCase	:  Tuple=None   ,				__lowerCAmelCase	:  Optional[int]=None   ,				**__lowerCAmelCase	:  Optional[Any]   ,				):
      super().__init__(**__lowerCAmelCase					)

      _UpperCAmelCase						 =      patch_size
      _UpperCAmelCase						 =      num_channels
      _UpperCAmelCase						 =      embed_dim
      _UpperCAmelCase						 =      depths
      _UpperCAmelCase						 =      len(__lowerCAmelCase					)
      _UpperCAmelCase						 =      num_heads
      _UpperCAmelCase						 =      kernel_size
      _UpperCAmelCase						 =      mlp_ratio
      _UpperCAmelCase						 =      qkv_bias
      _UpperCAmelCase						 =      hidden_dropout_prob
      _UpperCAmelCase						 =      attention_probs_dropout_prob
      _UpperCAmelCase						 =      drop_path_rate
      _UpperCAmelCase						 =      hidden_act
      _UpperCAmelCase						 =      layer_norm_eps
      _UpperCAmelCase						 =      initializer_range
      # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
      # this indicates the channel dimension after the last stage of the model
      _UpperCAmelCase						 =      int(embed_dim * 2 ** (len(__lowerCAmelCase					) - 1)					)
      _UpperCAmelCase						 =      layer_scale_init_value
      _UpperCAmelCase						 =      ["""stem"""] + [f'''stage{idx}''' for idx in range(1   ,				len(__lowerCAmelCase					) + 1					)]
      _UpperCAmelCase ,				_UpperCAmelCase						 =      get_aligned_output_features_output_indices(
          out_features=__lowerCAmelCase   ,				out_indices=__lowerCAmelCase   ,				stage_names=self.stage_names					)
