



import functools
import operator

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


a_						:     int	     =		logging.get_logger(__name__)

a_						:     List[Any]	     =		{
    'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}





class    lowerCamelCase__  (						UpperCAmelCase__):
					"""simple docstring"""



					_A       =			"sew-d"







					def __init__(self				,			__a=32				,			__a=7_68				,			__a=12				,			__a=12				,			__a=30_72				,			__a=2				,			__a=5_12				,			__a=2_56				,			__a=True				,			__a=True				,			__a=("p2c", "c2p")				,			__a="layer_norm"				,			__a="gelu_python"				,			__a=0.1				,			__a=0.1				,			__a=0.1				,			__a=0.0				,			__a=0.1				,			__a=0.02				,			__a=1E-7				,			__a=1E-5				,			__a="group"				,			__a="gelu"				,			__a=(64, 1_28, 1_28, 1_28, 1_28, 2_56, 2_56, 2_56, 2_56, 5_12, 5_12, 5_12, 5_12)				,			__a=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)				,			__a=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)				,			__a=False				,			__a=1_28				,			__a=16				,			__a=True				,			__a=0.05				,			__a=10				,			__a=2				,			__a=0.0				,			__a=10				,			__a=0				,			__a="mean"				,			__a=False				,			__a=False				,			__a=2_56				,			__a=0				,			__a=1				,			__a=2				,			**__a				,			):






											'''simple docstring'''



											super().__init__(**lowerCamelCase__				,			pad_token_id=lowerCamelCase__				,			bos_token_id=lowerCamelCase__				,			eos_token_id=lowerCamelCase__    )
											lowerCamelCase								=		hidden_size
											lowerCamelCase								=		feat_extract_norm
											lowerCamelCase								=		feat_extract_activation
											lowerCamelCase								=		list(lowerCamelCase__    )
											lowerCamelCase								=		list(lowerCamelCase__    )
											lowerCamelCase								=		list(lowerCamelCase__    )
											lowerCamelCase								=		conv_bias
											lowerCamelCase								=		num_conv_pos_embeddings
											lowerCamelCase								=		num_conv_pos_embedding_groups
											lowerCamelCase								=		len(self.conv_dim    )
											lowerCamelCase								=		num_hidden_layers
											lowerCamelCase								=		intermediate_size
											lowerCamelCase								=		squeeze_factor
											lowerCamelCase								=		max_position_embeddings
											lowerCamelCase								=		position_buckets
											lowerCamelCase								=		share_att_key
											lowerCamelCase								=		relative_attention
											lowerCamelCase								=		norm_rel_ebd
											lowerCamelCase								=		list(lowerCamelCase__    )
											lowerCamelCase								=		hidden_act
											lowerCamelCase								=		num_attention_heads
											lowerCamelCase								=		hidden_dropout
											lowerCamelCase								=		attention_dropout
											lowerCamelCase								=		activation_dropout
											lowerCamelCase								=		feat_proj_dropout
											lowerCamelCase								=		final_dropout
											lowerCamelCase								=		layer_norm_eps
											lowerCamelCase								=		feature_layer_norm_eps
											lowerCamelCase								=		initializer_range
											lowerCamelCase								=		vocab_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)`,"
																	    F"""but is `len(config.conv_dim) = {len(self.conv_dim    )}`, `len(config.conv_stride)"""
																	    F"""= {len(self.conv_stride    )}`, `len(config.conv_kernel) = {len(self.conv_kernel    )}`."""    )

											# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
											lowerCamelCase								=		apply_spec_augment
											lowerCamelCase								=		mask_time_prob
											lowerCamelCase								=		mask_time_length
											lowerCamelCase								=		mask_time_min_masks
											lowerCamelCase								=		mask_feature_prob
											lowerCamelCase								=		mask_feature_length
											lowerCamelCase								=		mask_feature_min_masks

											# ctc loss
											lowerCamelCase								=		ctc_loss_reduction
											lowerCamelCase								=		ctc_zero_infinity

											# sequence classification
											lowerCamelCase								=		use_weighted_layer_sum
											lowerCamelCase								=		classifier_proj_size







					@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    lowerCamelCase__  (						UpperCAmelCase_):
     """simple docstring"""



     _A       =			['image_processor', 'tokenizer']
     _A       =			'CLIPImageProcessor'
     _A       =			('CLIPTokenizer', 'CLIPTokenizerFast')







     def __init__(self				,			__a=None				,			__a=None				,			**__a    ):






           '''simple docstring'''



           lowerCamelCase								=		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				,			)
                 lowerCamelCase								=		kwargs.pop("feature_extractor"    )

           lowerCamelCase								=		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    ):






           '''simple docstring'''



           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:
                 lowerCamelCase								=		self.tokenizer(__a				,			return_tensors=__a				,			**__a    )

           if images is not None:
                 lowerCamelCase								=		self.image_processor(__a				,			return_tensors=__a				,			**__a    )

           if text is not None and images is not None:
                 lowerCamelCase								=		image_features.pixel_values
                 return encoding
           elif text is not None:
                 return encoding
           else:
                 return BatchEncoding(data=dict(**__a    )				,			tensor_type=__a    )







     def 						_a      (self				,			*__a				,			**__a    ):






           '''simple docstring'''



           return self.tokenizer.batch_decode(*__a				,			**__a    )







     def 						_a      (self				,			*__a				,			**__a    ):






           '''simple docstring'''



           return self.tokenizer.decode(*__a				,			**__a    )







     @property
     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		self.tokenizer.model_input_names
           lowerCamelCase								=		self.image_processor.model_input_names
           return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names    )    )







     @property
     def 						_a      (self    ):






           '''simple docstring'''



           warnings.warn(
               "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."				,			__a				,			)
           return self.image_processor_class







     @property
     def 						_a      (self    ):






           '''simple docstring'''



           warnings.warn(
               "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."				,			__a				,			)
           return self.image_processor