





"""simple docstring"""




import functools
import operator

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


UpperCamelCase_									=logging.get_logger(__name__)

UpperCamelCase_									={
    """microsoft/unispeech-large-1500h-cv""": (
        """https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json"""
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''unispeech'''






				def __init__(			self		:   Optional[Any],			lowerCAmelCase__		:   List[Any]=3_2,			lowerCAmelCase__		:   List[Any]=7_6_8,			lowerCAmelCase__		:   List[str]=1_2,			lowerCAmelCase__		:   List[str]=1_2,			lowerCAmelCase__		:   Any=3_0_7_2,			lowerCAmelCase__		:   Any="gelu",			lowerCAmelCase__		:   Union[str, Any]=0.1,			lowerCAmelCase__		:   List[Any]=0.1,			lowerCAmelCase__		:   Optional[int]=0.1,			lowerCAmelCase__		:   Optional[Any]=0.0,			lowerCAmelCase__		:   str=0.0,			lowerCAmelCase__		:   Union[str, Any]=0.1,			lowerCAmelCase__		:   Optional[int]=0.1,			lowerCAmelCase__		:   Optional[Any]=0.02,			lowerCAmelCase__		:   Tuple=1e-5,			lowerCAmelCase__		:   Tuple="group",			lowerCAmelCase__		:   List[str]="gelu",			lowerCAmelCase__		:   List[str]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2),			lowerCAmelCase__		:   List[Any]=(5, 2, 2, 2, 2, 2, 2),			lowerCAmelCase__		:   Optional[int]=(1_0, 3, 3, 3, 3, 2, 2),			lowerCAmelCase__		:   str=False,			lowerCAmelCase__		:   Optional[Any]=1_2_8,			lowerCAmelCase__		:   List[Any]=1_6,			lowerCAmelCase__		:   Union[str, Any]=False,			lowerCAmelCase__		:   Any=True,			lowerCAmelCase__		:   Dict=0.05,			lowerCAmelCase__		:   Any=1_0,			lowerCAmelCase__		:   Optional[int]=2,			lowerCAmelCase__		:   Optional[Any]=0.0,			lowerCAmelCase__		:   Dict=1_0,			lowerCAmelCase__		:   Dict=0,			lowerCAmelCase__		:   List[Any]=3_2_0,			lowerCAmelCase__		:   List[Any]=2,			lowerCAmelCase__		:   List[str]=0.1,			lowerCAmelCase__		:   str=1_0_0,			lowerCAmelCase__		:   int=2_5_6,			lowerCAmelCase__		:   str=2_5_6,			lowerCAmelCase__		:   Optional[Any]=0.1,			lowerCAmelCase__		:   Union[str, Any]="mean",			lowerCAmelCase__		:   Any=False,			lowerCAmelCase__		:   List[str]=False,			lowerCAmelCase__		:   Union[str, Any]=2_5_6,			lowerCAmelCase__		:   Dict=8_0,			lowerCAmelCase__		:   Any=0,			lowerCAmelCase__		:   Dict=1,			lowerCAmelCase__		:   Optional[Any]=2,			lowerCAmelCase__		:   Union[str, Any]=0.5,			**lowerCAmelCase__		:   Any,			)     ->				Tuple:




										'''simple docstring'''



										super().__init__(**lowerCAmelCase__,			pad_token_id=lowerCAmelCase__,			bos_token_id=lowerCAmelCase__,			eos_token_id=lowerCAmelCase__							)
										_UpperCamelCase      : Dict         =   hidden_size
										_UpperCamelCase      : List[Any]         =   feat_extract_norm
										_UpperCamelCase      : List[str]         =   feat_extract_activation
										_UpperCamelCase      : Optional[int]         =   list(lowerCAmelCase__							)
										_UpperCamelCase      : Tuple         =   list(lowerCAmelCase__							)
										_UpperCamelCase      : Any         =   list(lowerCAmelCase__							)
										_UpperCamelCase      : Union[str, Any]         =   conv_bias
										_UpperCamelCase      : Optional[Any]         =   num_conv_pos_embeddings
										_UpperCamelCase      : Dict         =   num_conv_pos_embedding_groups
										_UpperCamelCase      : str         =   len(self.conv_dim							)
										_UpperCamelCase      : Tuple         =   num_hidden_layers
										_UpperCamelCase      : List[str]         =   intermediate_size
										_UpperCamelCase      : int         =   hidden_act
										_UpperCamelCase      : List[Any]         =   num_attention_heads
										_UpperCamelCase      : int         =   hidden_dropout
										_UpperCamelCase      : Tuple         =   attention_dropout
										_UpperCamelCase      : str         =   activation_dropout
										_UpperCamelCase      : Optional[int]         =   feat_proj_dropout
										_UpperCamelCase      : Optional[Any]         =   final_dropout
										_UpperCamelCase      : Optional[int]         =   layerdrop
										_UpperCamelCase      : Tuple         =   layer_norm_eps
										_UpperCamelCase      : Union[str, Any]         =   initializer_range
										_UpperCamelCase      : str         =   num_ctc_classes
										_UpperCamelCase      : Tuple         =   vocab_size
										_UpperCamelCase      : Tuple         =   do_stable_layer_norm
										_UpperCamelCase      : List[Any]         =   use_weighted_layer_sum
										_UpperCamelCase      : Tuple         =   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      : Optional[Any]         =   apply_spec_augment
										_UpperCamelCase      : str         =   mask_time_prob
										_UpperCamelCase      : List[str]         =   mask_time_length
										_UpperCamelCase      : Tuple         =   mask_time_min_masks
										_UpperCamelCase      : List[Any]         =   mask_feature_prob
										_UpperCamelCase      : int         =   mask_feature_length
										_UpperCamelCase      : int         =   mask_feature_min_masks

										# parameters for pretraining with codevector quantized representations
										_UpperCamelCase      : List[Any]         =   num_codevectors_per_group
										_UpperCamelCase      : List[str]         =   num_codevector_groups
										_UpperCamelCase      : List[Any]         =   contrastive_logits_temperature
										_UpperCamelCase      : Union[str, Any]         =   feat_quantizer_dropout
										_UpperCamelCase      : Dict         =   num_negatives
										_UpperCamelCase      : Tuple         =   codevector_dim
										_UpperCamelCase      : str         =   proj_codevector_dim
										_UpperCamelCase      : Optional[int]         =   diversity_loss_weight

										# ctc loss
										_UpperCamelCase      : List[str]         =   ctc_loss_reduction
										_UpperCamelCase      : Optional[Any]         =   ctc_zero_infinity

										# pretraining loss
										_UpperCamelCase      : List[Any]         =   replace_prob






				@property
				def     snake_case     (			self		:   List[Any]							)     ->				str:




										'''simple docstring'''



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










"""simple docstring"""




from ...processing_utils import ProcessorMixin




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   ['''image_processor''', '''feature_extractor''']
				UpperCamelCase								=   '''TvltImageProcessor'''
				UpperCamelCase								=   '''TvltFeatureExtractor'''






				def __init__(			self		:   Union[str, Any],			lowerCAmelCase__		:   str,			lowerCAmelCase__		:   List[str]							)     ->				Optional[Any]:




										'''simple docstring'''



										super().__init__(image_processor=lowerCAmelCase__,			feature_extractor=lowerCAmelCase__							)

										_UpperCamelCase      : List[str]         =   image_processor
										_UpperCamelCase      : int         =   feature_extractor






				def __call__(			self		:   List[str],			lowerCAmelCase__		:   Optional[int]=None,			lowerCAmelCase__		:   str=None,			lowerCAmelCase__		:   Dict=None,			lowerCAmelCase__		:   str=None,			lowerCAmelCase__		:   Optional[int]=False,			lowerCAmelCase__		:   str=False,			*lowerCAmelCase__		:   List[str],			**lowerCAmelCase__		:   Optional[int],			)     ->				Dict:




										'''simple docstring'''



										if images is None and audio is None:
																raise ValueError('''You need to specify either an `images` or `audio` input to process.'''							)

										_UpperCamelCase      : Optional[int]         =   None
										if images is not None:
																_UpperCamelCase      : Optional[int]         =   self.image_processor(lowerCAmelCase__,			mask_pixel=lowerCAmelCase__,			*lowerCAmelCase__,			**lowerCAmelCase__							)
										if images_mixed is not None:
																_UpperCamelCase      : str         =   self.image_processor(lowerCAmelCase__,			is_mixed=lowerCAmelCase__,			*lowerCAmelCase__,			**lowerCAmelCase__							)
										if audio is not None:
																_UpperCamelCase      : Union[str, Any]         =   self.feature_extractor(
																    lowerCAmelCase__,			*lowerCAmelCase__,			sampling_rate=lowerCAmelCase__,			mask_audio=lowerCAmelCase__,			**lowerCAmelCase__							)

										_UpperCamelCase      : str         =   {}
										if audio is not None:
																output_dict.update(lowerCAmelCase__							)
										if images is not None:
																output_dict.update(lowerCAmelCase__							)
										if images_mixed_dict is not None:
																output_dict.update(lowerCAmelCase__							)
										return output_dict






				@property
				def     snake_case     (			self		:   List[str]							)     ->				Tuple:




										'''simple docstring'''



										_UpperCamelCase      : List[str]         =   self.image_processor.model_input_names
										_UpperCamelCase      : List[Any]         =   self.feature_extractor.model_input_names
										return list(dict.fromkeys(image_processor_input_names + feature_extractor_input_names							)							)



