

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowerCAmelCase						:   Any										=    {
    '''configuration_oneformer''': ['''ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''OneFormerConfig'''],
    '''processing_oneformer''': ['''OneFormerProcessor'''],
}

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCAmelCase						:   str										=    ['''OneFormerImageProcessor''']

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCAmelCase						:   List[Any]										=    [
           '''ONEFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''OneFormerForUniversalSegmentation''',
           '''OneFormerModel''',
           '''OneFormerPreTrainedModel''',
       ]

if TYPE_CHECKING:
       from .configuration_oneformer import ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, OneFormerConfig
       from .processing_oneformer import OneFormerProcessor

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .image_processing_oneformer import OneFormerImageProcessor
       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_oneformer import (
                  ONEFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
                  OneFormerForUniversalSegmentation,
                  OneFormerModel,
                  OneFormerPreTrainedModel,
              )


else:
       import sys

       lowerCAmelCase						:   Optional[int]										=    _LazyModule(__name__, globals()['''__file__'''], _import_structure)









import functools
import operator

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


lowerCAmelCase						:   Dict										=    logging.get_logger(__name__)

lowerCAmelCase						:   str										=    {
    '''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     SCREAMING_SNAKE_CASE__     (						__a		):





       '''simple docstring'''




       UpperCamelCase__ :     Tuple				    =       '''hubert'''

       def __init__(						self       :						Union[str, Any]    ,		lowerCAmelCase__       :						List[Any]=32    ,		lowerCAmelCase__       :						Any=768    ,		lowerCAmelCase__       :						List[Any]=12    ,		lowerCAmelCase__       :						Tuple=12    ,		lowerCAmelCase__       :						Optional[int]=3072    ,		lowerCAmelCase__       :						Dict="gelu"    ,		lowerCAmelCase__       :						List[str]=0.1    ,		lowerCAmelCase__       :						str=0.1    ,		lowerCAmelCase__       :						List[str]=0.1    ,		lowerCAmelCase__       :						int=True    ,		lowerCAmelCase__       :						Tuple=0.0    ,		lowerCAmelCase__       :						Union[str, Any]=0.1    ,		lowerCAmelCase__       :						Dict=0.1    ,		lowerCAmelCase__       :						int=0.02    ,		lowerCAmelCase__       :						Optional[int]=1E-5    ,		lowerCAmelCase__       :						List[str]="group"    ,		lowerCAmelCase__       :						List[str]="gelu"    ,		lowerCAmelCase__       :						Any=(512, 512, 512, 512, 512, 512, 512)    ,		lowerCAmelCase__       :						str=(5, 2, 2, 2, 2, 2, 2)    ,		lowerCAmelCase__       :						Union[str, Any]=(10, 3, 3, 3, 3, 2, 2)    ,		lowerCAmelCase__       :						Optional[Any]=False    ,		lowerCAmelCase__       :						Dict=128    ,		lowerCAmelCase__       :						List[Any]=16    ,		lowerCAmelCase__       :						Optional[Any]=False    ,		lowerCAmelCase__       :						Optional[int]=True    ,		lowerCAmelCase__       :						List[Any]=0.05    ,		lowerCAmelCase__       :						Any=10    ,		lowerCAmelCase__       :						Dict=2    ,		lowerCAmelCase__       :						Dict=0.0    ,		lowerCAmelCase__       :						Tuple=10    ,		lowerCAmelCase__       :						List[str]=0    ,		lowerCAmelCase__       :						int="sum"    ,		lowerCAmelCase__       :						Optional[Any]=False    ,		lowerCAmelCase__       :						List[Any]=False    ,		lowerCAmelCase__       :						int=256    ,		lowerCAmelCase__       :						List[Any]=0    ,		lowerCAmelCase__       :						Union[str, Any]=1    ,		lowerCAmelCase__       :						Tuple=2    ,		**lowerCAmelCase__       :						str    ,		)			->    Union[str, Any]:
             super().__init__(**lowerCAmelCase__    ,		pad_token_id=lowerCAmelCase__    ,		bos_token_id=lowerCAmelCase__    ,		eos_token_id=lowerCAmelCase__							)
             snake_case__					=   hidden_size
             snake_case__					=   feat_extract_norm
             snake_case__					=   feat_extract_activation
             snake_case__					=   list(lowerCAmelCase__							)
             snake_case__					=   list(lowerCAmelCase__							)
             snake_case__					=   list(lowerCAmelCase__							)
             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 UpperCAmelCase_						(						self       :						Union[str, Any]							)			->    Tuple:
             return functools.reduce(operator.mul    ,		self.conv_stride    ,		1							)






