

import copy
from typing import Dict

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING
from ..bit import BitConfig


UpperCamelCase__		   =    logging.get_logger(__name__)

UpperCamelCase__		   =    {
    '''google/vit-hybrid-base-bit-384''': '''https://huggingface.co/vit-hybrid-base-bit-384/resolve/main/config.json''',
    # See all ViT hybrid models at https://huggingface.co/models?filter=vit
}

class 						__snake_case						(							snake_case__     ):
       """simple docstring"""







       __SCREAMING_SNAKE_CASE													=       "vit-hybrid"


       def __init__(		self			,   _UpperCamelCase=None			,   _UpperCamelCase=7_68			,   _UpperCamelCase=12			,   _UpperCamelCase=12			,   _UpperCamelCase=30_72			,   _UpperCamelCase="gelu"			,   _UpperCamelCase=0.0			,   _UpperCamelCase=0.0			,   _UpperCamelCase=0.02			,   _UpperCamelCase=1E-12			,   _UpperCamelCase=2_24			,   _UpperCamelCase=1			,   _UpperCamelCase=3			,   _UpperCamelCase=[1, 10_24, 24, 24]			,   _UpperCamelCase=True			,   **_UpperCamelCase			,   )			->       Optional[Any]:






              """simple docstring"""


              super().__init__(**_UpperCamelCase      )

              if backbone_config is None:
                     logger.info("""`backbone_config` is `None`. Initializing the config with a `BiT` backbone."""      )
                     __snake_case					  =       {
                         """global_padding""": """same""",
                         """layer_type""": """bottleneck""",
                         """depths""": [3, 4, 9],
                         """out_features""": ["""stage3"""],
                         """embedding_dynamic_padding""": True,
                     }

              if isinstance(_UpperCamelCase			,   _UpperCamelCase      ):
                     if "model_type" in backbone_config:
                            __snake_case					  =       CONFIG_MAPPING[backbone_config["""model_type"""]]
                     else:
                            logger.info(
                                """`model_type` is not found in `backbone_config`. Use `Bit` as the backbone configuration class."""      )
                            __snake_case					  =       BitConfig
                     __snake_case					  =       backbone_config_class(**_UpperCamelCase      )

              __snake_case					  =       backbone_featmap_shape
              __snake_case					  =       backbone_config
              __snake_case					  =       hidden_size
              __snake_case					  =       num_hidden_layers
              __snake_case					  =       num_attention_heads
              __snake_case					  =       intermediate_size
              __snake_case					  =       hidden_act
              __snake_case					  =       hidden_dropout_prob
              __snake_case					  =       attention_probs_dropout_prob
              __snake_case					  =       initializer_range
              __snake_case					  =       layer_norm_eps
              __snake_case					  =       image_size
              __snake_case					  =       patch_size
              __snake_case					  =       num_channels
              __snake_case					  =       qkv_bias






       def  a		(		self      )			->       Dict[str, any]:






              """simple docstring"""


              __snake_case					  =       copy.deepcopy(self.__dict__      )
              __snake_case					  =       self.backbone_config.to_dict()
              __snake_case					  =       self.__class__.model_type
              return output




import functools
import operator

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


UpperCamelCase__		   =    logging.get_logger(__name__)

UpperCamelCase__		   =    {
    '''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						(							snake_case__     ):
       """simple docstring"""







       __SCREAMING_SNAKE_CASE													=       "hubert"


       def __init__(		self			,   _UpperCamelCase=32			,   _UpperCamelCase=7_68			,   _UpperCamelCase=12			,   _UpperCamelCase=12			,   _UpperCamelCase=30_72			,   _UpperCamelCase="gelu"			,   _UpperCamelCase=0.1			,   _UpperCamelCase=0.1			,   _UpperCamelCase=0.1			,   _UpperCamelCase=True			,   _UpperCamelCase=0.0			,   _UpperCamelCase=0.1			,   _UpperCamelCase=0.1			,   _UpperCamelCase=0.02			,   _UpperCamelCase=1E-5			,   _UpperCamelCase="group"			,   _UpperCamelCase="gelu"			,   _UpperCamelCase=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)			,   _UpperCamelCase=(5, 2, 2, 2, 2, 2, 2)			,   _UpperCamelCase=(10, 3, 3, 3, 3, 2, 2)			,   _UpperCamelCase=False			,   _UpperCamelCase=1_28			,   _UpperCamelCase=16			,   _UpperCamelCase=False			,   _UpperCamelCase=True			,   _UpperCamelCase=0.05			,   _UpperCamelCase=10			,   _UpperCamelCase=2			,   _UpperCamelCase=0.0			,   _UpperCamelCase=10			,   _UpperCamelCase=0			,   _UpperCamelCase="sum"			,   _UpperCamelCase=False			,   _UpperCamelCase=False			,   _UpperCamelCase=2_56			,   _UpperCamelCase=0			,   _UpperCamelCase=1			,   _UpperCamelCase=2			,   **_UpperCamelCase			,   )			->       Any:






              """simple docstring"""


              super().__init__(**_UpperCamelCase			,   pad_token_id=_UpperCamelCase			,   bos_token_id=_UpperCamelCase			,   eos_token_id=_UpperCamelCase      )
              __snake_case					  =       hidden_size
              __snake_case					  =       feat_extract_norm
              __snake_case					  =       feat_extract_activation
              __snake_case					  =       list(_UpperCamelCase      )
              __snake_case					  =       list(_UpperCamelCase      )
              __snake_case					  =       list(_UpperCamelCase      )
              __snake_case					  =       conv_bias
              __snake_case					  =       num_conv_pos_embeddings
              __snake_case					  =       num_conv_pos_embedding_groups
              __snake_case					  =       len(self.conv_dim      )
              __snake_case					  =       num_hidden_layers
              __snake_case					  =       intermediate_size
              __snake_case					  =       hidden_act
              __snake_case					  =       num_attention_heads
              __snake_case					  =       hidden_dropout
              __snake_case					  =       attention_dropout
              __snake_case					  =       activation_dropout
              __snake_case					  =       feat_proj_layer_norm
              __snake_case					  =       feat_proj_dropout
              __snake_case					  =       final_dropout
              __snake_case					  =       layerdrop
              __snake_case					  =       layer_norm_eps
              __snake_case					  =       initializer_range
              __snake_case					  =       vocab_size
              __snake_case					  =       do_stable_layer_norm
              __snake_case					  =       use_weighted_layer_sum
              __snake_case					  =       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
              __snake_case					  =       apply_spec_augment
              __snake_case					  =       mask_time_prob
              __snake_case					  =       mask_time_length
              __snake_case					  =       mask_time_min_masks
              __snake_case					  =       mask_feature_prob
              __snake_case					  =       mask_feature_length
              __snake_case					  =       mask_feature_min_masks

              # ctc loss
              __snake_case					  =       ctc_loss_reduction
              __snake_case					  =       ctc_zero_infinity






       @property
       def  a		(		self      )			->       Union[str, Any]:






              """simple docstring"""


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

