
import functools
import operator

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


__magic_name__   				=     logging.get_logger(__name__)

__magic_name__   				=     {
    '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       ):
      _A  :						Union[str, Any]					=   'hubert'
      def __init__(	self						,		lowerCamelCase=32						,		lowerCamelCase=7_68						,		lowerCamelCase=12						,		lowerCamelCase=12						,		lowerCamelCase=30_72						,		lowerCamelCase="gelu"						,		lowerCamelCase=0.1						,		lowerCamelCase=0.1						,		lowerCamelCase=0.1						,		lowerCamelCase=True						,		lowerCamelCase=0.0						,		lowerCamelCase=0.1						,		lowerCamelCase=0.1						,		lowerCamelCase=0.0_2						,		lowerCamelCase=1e-5						,		lowerCamelCase="group"						,		lowerCamelCase="gelu"						,		lowerCamelCase=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)						,		lowerCamelCase=(5, 2, 2, 2, 2, 2, 2)						,		lowerCamelCase=(10, 3, 3, 3, 3, 2, 2)						,		lowerCamelCase=False						,		lowerCamelCase=1_28						,		lowerCamelCase=16						,		lowerCamelCase=False						,		lowerCamelCase=True						,		lowerCamelCase=0.0_5						,		lowerCamelCase=10						,		lowerCamelCase=2						,		lowerCamelCase=0.0						,		lowerCamelCase=10						,		lowerCamelCase=0						,		lowerCamelCase="sum"						,		lowerCamelCase=False						,		lowerCamelCase=False						,		lowerCamelCase=2_56						,		lowerCamelCase=0						,		lowerCamelCase=1						,		lowerCamelCase=2						,		**lowerCamelCase						,		):
          super().__init__(**__SCREAMING_SNAKE_CASE						,		pad_token_id=__SCREAMING_SNAKE_CASE						,		bos_token_id=__SCREAMING_SNAKE_CASE						,		eos_token_id=__SCREAMING_SNAKE_CASE       )
          snake_case__  = hidden_size
          snake_case__  = feat_extract_norm
          snake_case__  = feat_extract_activation
          snake_case__  = list(__SCREAMING_SNAKE_CASE       )
          snake_case__  = list(__SCREAMING_SNAKE_CASE       )
          snake_case__  = list(__SCREAMING_SNAKE_CASE       )
          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       ):
          return functools.reduce(operator.mul						,		self.conv_stride						,		1       )






"""simple docstring"""




import copy

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


__A     :    str    =		logging.get_logger(__name__)

__A     :    Union[str, Any]    =		{
    'facebook/sam-vit-huge': 'https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json',
    'facebook/sam-vit-large': 'https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json',
    'facebook/sam-vit-base': 'https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json',
}





class 			__UpperCamelCase (   _A						):


		def __init__(self :		int     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=2_5_6     ,     __SCREAMING_SNAKE_CASE :		List[str]=1_0_2_4     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_6     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_6     ,     __SCREAMING_SNAKE_CASE :		List[str]=4     ,     __SCREAMING_SNAKE_CASE :		List[Any]="gelu"     ,     __SCREAMING_SNAKE_CASE :		str=1E-6     ,     **__SCREAMING_SNAKE_CASE :		Optional[int]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					hidden_size
							A			=					image_size
							A			=					patch_size
							A			=					image_size // patch_size
							A			=					mask_input_channels
							A			=					num_point_embeddings
							A			=					hidden_act
							A			=					layer_norm_eps





class 			__UpperCamelCase (   _A						):


		def __init__(self :		List[Any]     ,     __SCREAMING_SNAKE_CASE :		Tuple=2_5_6     ,     __SCREAMING_SNAKE_CASE :		str="relu"     ,     __SCREAMING_SNAKE_CASE :		List[Any]=2_0_4_8     ,     __SCREAMING_SNAKE_CASE :		Tuple=2     ,     __SCREAMING_SNAKE_CASE :		Any=8     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=2     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=3     ,     __SCREAMING_SNAKE_CASE :		List[Any]=3     ,     __SCREAMING_SNAKE_CASE :		Tuple=2_5_6     ,     __SCREAMING_SNAKE_CASE :		int=1E-6     ,     **__SCREAMING_SNAKE_CASE :		int     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					hidden_size
							A			=					hidden_act
							A			=					mlp_dim
							A			=					num_hidden_layers
							A			=					num_attention_heads
							A			=					attention_downsample_rate
							A			=					num_multimask_outputs
							A			=					iou_head_depth
							A			=					iou_head_hidden_dim
							A			=					layer_norm_eps





class 			__UpperCamelCase (   _A						):


		def __init__(self :		List[str]     ,     __SCREAMING_SNAKE_CASE :		List[Any]=7_6_8     ,     __SCREAMING_SNAKE_CASE :		int=2_5_6     ,     __SCREAMING_SNAKE_CASE :		Tuple=1_2     ,     __SCREAMING_SNAKE_CASE :		str=1_2     ,     __SCREAMING_SNAKE_CASE :		Any=3     ,     __SCREAMING_SNAKE_CASE :		Dict=1_0_2_4     ,     __SCREAMING_SNAKE_CASE :		str=1_6     ,     __SCREAMING_SNAKE_CASE :		Tuple="gelu"     ,     __SCREAMING_SNAKE_CASE :		int=1E-06     ,     __SCREAMING_SNAKE_CASE :		Dict=0.0     ,     __SCREAMING_SNAKE_CASE :		str=1E-10     ,     __SCREAMING_SNAKE_CASE :		List[str]=True     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=4.0     ,     __SCREAMING_SNAKE_CASE :		str=True     ,     __SCREAMING_SNAKE_CASE :		Any=True     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_4     ,     __SCREAMING_SNAKE_CASE :		Tuple=[2, 5, 8, 1_1]     ,     __SCREAMING_SNAKE_CASE :		str=1_2_8     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=None     ,     **__SCREAMING_SNAKE_CASE :		Optional[Any]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)

							A			=					hidden_size
							A			=					output_channels
							A			=					num_hidden_layers
							A			=					num_attention_heads
							A			=					num_channels
							A			=					image_size
							A			=					patch_size
							A			=					hidden_act
							A			=					layer_norm_eps
							A			=					attention_dropout
							A			=					initializer_range
							A			=					qkv_bias
							A			=					mlp_ratio
							A			=					use_abs_pos
							A			=					use_rel_pos
							A			=					window_size
							A			=					global_attn_indexes
							A			=					num_pos_feats
							A			=					int(hidden_size * mlp_ratio) if mlp_dim is None else mlp_dim





class 			__UpperCamelCase (   _A						):
		SCREAMING_SNAKE_CASE								=    "sam"
		SCREAMING_SNAKE_CASE								=    True


		def __init__(self :		Optional[int]     ,     __SCREAMING_SNAKE_CASE :		Dict=None     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=None     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=None     ,     __SCREAMING_SNAKE_CASE :		List[Any]=0.0_2     ,     **__SCREAMING_SNAKE_CASE :		Optional[Any]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					vision_config if vision_config is not None else {}
							A			=					prompt_encoder_config if prompt_encoder_config is not None else {}
							A			=					mask_decoder_config if mask_decoder_config is not None else {}

							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					vision_config.to_dict()
							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					prompt_encoder_config.to_dict()
							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					mask_decoder_config.to_dict()

							A			=					SamVisionConfig(**__SCREAMING_SNAKE_CASE)
							A			=					SamPromptEncoderConfig(**__SCREAMING_SNAKE_CASE)
							A			=					SamMaskDecoderConfig(**__SCREAMING_SNAKE_CASE)
							A			=					initializer_range


		def 					SCREAMING_SNAKE_CASE__   (self :		List[str]):
							A			=					copy.deepcopy(self.__dict__)
							A			=					self.vision_config.to_dict()
							A			=					self.prompt_encoder_config.to_dict()
							A			=					self.mask_decoder_config.to_dict()
							A			=					self.__class__.model_type
							return output





