

"""simple docstring"""
import functools
import operator

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


_A						 =   logging.get_logger(__name__)

_A						 =   {
    """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 	lowerCamelCase     (    __lowercase					):


  '''simple docstring'''







  SCREAMING_SNAKE_CASE 	=   "unispeech"



  def __init__(self				,    _lowerCamelCase=32				,    _lowerCamelCase=768				,    _lowerCamelCase=12				,    _lowerCamelCase=12				,    _lowerCamelCase=3072				,    _lowerCamelCase="gelu"				,    _lowerCamelCase=0.1				,    _lowerCamelCase=0.1				,    _lowerCamelCase=0.1				,    _lowerCamelCase=0.0				,    _lowerCamelCase=0.0				,    _lowerCamelCase=0.1				,    _lowerCamelCase=0.1				,    _lowerCamelCase=0.02				,    _lowerCamelCase=1e-5				,    _lowerCamelCase="group"				,    _lowerCamelCase="gelu"				,    _lowerCamelCase=(512, 512, 512, 512, 512, 512, 512)				,    _lowerCamelCase=(5, 2, 2, 2, 2, 2, 2)				,    _lowerCamelCase=(10, 3, 3, 3, 3, 2, 2)				,    _lowerCamelCase=False				,    _lowerCamelCase=128				,    _lowerCamelCase=16				,    _lowerCamelCase=False				,    _lowerCamelCase=True				,    _lowerCamelCase=0.05				,    _lowerCamelCase=10				,    _lowerCamelCase=2				,    _lowerCamelCase=0.0				,    _lowerCamelCase=10				,    _lowerCamelCase=0				,    _lowerCamelCase=320				,    _lowerCamelCase=2				,    _lowerCamelCase=0.1				,    _lowerCamelCase=100				,    _lowerCamelCase=256				,    _lowerCamelCase=256				,    _lowerCamelCase=0.1				,    _lowerCamelCase="mean"				,    _lowerCamelCase=False				,    _lowerCamelCase=False				,    _lowerCamelCase=256				,    _lowerCamelCase=80				,    _lowerCamelCase=0				,    _lowerCamelCase=1				,    _lowerCamelCase=2				,    _lowerCamelCase=0.5				,    **_lowerCamelCase				,    ):


        """simple docstring"""

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

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

        # ctc loss
        UpperCAmelCase__       :				Any						 =  ctc_loss_reduction
        UpperCAmelCase__       :				List[Any]						 =  ctc_zero_infinity

        # pretraining loss
        UpperCAmelCase__       :				List[Any]						 =  replace_prob




  @property
  def       _a	(self     ):


        """simple docstring"""

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




import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding

class 				UpperCAmelCase_		(			__lowercase   ):
							"""simple docstring"""







							UpperCAmelCase__       :						str	    =    ["image_processor", "tokenizer"]
							UpperCAmelCase__       :						Optional[int]	    =    "CLIPImageProcessor"
							UpperCAmelCase__       :						Tuple	    =    ("XLMRobertaTokenizer", "XLMRobertaTokenizerFast")


							def __init__(			self       ,							_a=None       ,							_a=None       ,							**_a       )    ->    Any:
												_a	:    int         =		None
												if "feature_extractor" in kwargs:
																	warnings.warn(
																	    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
																	    ''' instead.'''       ,							_a       ,							)
																	_a	:    int         =		kwargs.pop('''feature_extractor'''       )

												_a	:    int         =		image_processor if image_processor is not None else feature_extractor
												if image_processor is None:
																	raise ValueError('''You need to specify an `image_processor`.'''       )
												if tokenizer is None:
																	raise ValueError('''You need to specify a `tokenizer`.'''       )

												super().__init__(_a       ,							_a       )


							def __call__(			self       ,							_a=None       ,							_a=None       ,							_a=None       ,							**_a       )    ->    List[Any]:

												if text is None and images is None:
																	raise ValueError('''You have to specify either text or images. Both cannot be none.'''       )

												if text is not None:
																	_a	:    str         =		self.tokenizer(_a       ,							return_tensors=_a       ,							**_a       )

												if images is not None:
																	_a	:    Optional[Any]         =		self.image_processor(_a       ,							return_tensors=_a       ,							**_a       )

												if text is not None and images is not None:
																	_a	:    List[Any]         =		image_features.pixel_values
																	return encoding
												elif text is not None:
																	return encoding
												else:
																	return BatchEncoding(data=dict(**_a       )       ,							tensor_type=_a       )


							def 				__lowercase				(			self       ,							*_a       ,							**_a       )    ->    Optional[Any]:
												return self.tokenizer.batch_decode(*_a       ,							**_a       )


							def 				__lowercase				(			self       ,							*_a       ,							**_a       )    ->    Optional[int]:
												return self.tokenizer.decode(*_a       ,							**_a       )




							@property
							def 				__lowercase				(			self       )    ->    Optional[int]:
												_a	:    Dict         =		self.tokenizer.model_input_names
												_a	:    Dict         =		self.image_processor.model_input_names
												return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )



