

import functools
import operator

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


snake_case_        =			logging.get_logger(__name__)

snake_case_        =			{
    '''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 				SCREAMING_SNAKE_CASE__ (lowercase__					):
				__lowerCamelCase						:	Any														=					"""sew-d"""





				def __init__(				self						,       a=32						,       a=768						,       a=12						,       a=12						,       a=3072						,       a=2						,       a=512						,       a=256						,       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, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)						,       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=128						,       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=256						,       a=0						,       a=1						,       a=2						,       **a						,       ):
									super().__init__(**lowercase_						,       pad_token_id=lowercase_						,       bos_token_id=lowercase_						,       eos_token_id=lowercase_)
									lowercase__   :       Tuple				=	hidden_size
									lowercase__   :       Dict				=	feat_extract_norm
									lowercase__   :       Tuple				=	feat_extract_activation
									lowercase__   :       str				=	list(lowercase_)
									lowercase__   :       Tuple				=	list(lowercase_)
									lowercase__   :       List[str]				=	list(lowercase_)
									lowercase__   :       Dict				=	conv_bias
									lowercase__   :       int				=	num_conv_pos_embeddings
									lowercase__   :       str				=	num_conv_pos_embedding_groups
									lowercase__   :       int				=	len(self.conv_dim)
									lowercase__   :       List[str]				=	num_hidden_layers
									lowercase__   :       Optional[int]				=	intermediate_size
									lowercase__   :       Tuple				=	squeeze_factor
									lowercase__   :       Tuple				=	max_position_embeddings
									lowercase__   :       Tuple				=	position_buckets
									lowercase__   :       Optional[int]				=	share_att_key
									lowercase__   :       Dict				=	relative_attention
									lowercase__   :       List[Any]				=	norm_rel_ebd
									lowercase__   :       Optional[int]				=	list(lowercase_)
									lowercase__   :       List[str]				=	hidden_act
									lowercase__   :       Union[str, Any]				=	num_attention_heads
									lowercase__   :       List[str]				=	hidden_dropout
									lowercase__   :       Optional[int]				=	attention_dropout
									lowercase__   :       Optional[Any]				=	activation_dropout
									lowercase__   :       Tuple				=	feat_proj_dropout
									lowercase__   :       Optional[int]				=	final_dropout
									lowercase__   :       Optional[int]				=	layer_norm_eps
									lowercase__   :       Union[str, Any]				=	feature_layer_norm_eps
									lowercase__   :       Optional[Any]				=	initializer_range
									lowercase__   :       int				=	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
									lowercase__   :       Optional[int]				=	apply_spec_augment
									lowercase__   :       Dict				=	mask_time_prob
									lowercase__   :       Optional[Any]				=	mask_time_length
									lowercase__   :       List[str]				=	mask_time_min_masks
									lowercase__   :       Dict				=	mask_feature_prob
									lowercase__   :       int				=	mask_feature_length
									lowercase__   :       Any				=	mask_feature_min_masks

									# ctc loss
									lowercase__   :       Tuple				=	ctc_loss_reduction
									lowercase__   :       Tuple				=	ctc_zero_infinity

									# sequence classification
									lowercase__   :       Any				=	use_weighted_layer_sum
									lowercase__   :       Union[str, Any]				=	classifier_proj_size





				@property
				def 				snake_case_    (				self):
									return functools.reduce(operator.mul						,       self.conv_stride						,       1)




import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType


class 				SCREAMING_SNAKE_CASE__ (__snake_case					):
    __lowerCamelCase						:	Tuple														=					["""image_processor""", """tokenizer"""]
    __lowerCamelCase						:	int														=					"""ViltImageProcessor"""
    __lowerCamelCase						:	Union[str, Any]														=					("""BertTokenizer""", """BertTokenizerFast""")





    def __init__(				self						,       a=None						,       a=None						,       **a):
         lowercase__   :       Any				=	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						,       )
              lowercase__   :       Union[str, Any]				=	kwargs.pop('feature_extractor')

         lowercase__   :       List[Any]				=	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)
         lowercase__   :       str				=	self.image_processor





    def __call__(				self						,       a						,       a = None						,       a = True						,       a = False						,       a = None						,       a = None						,       a = 0						,       a = None						,       a = None						,       a = None						,       a = False						,       a = False						,       a = False						,       a = False						,       a = True						,       a = None						,       **a						,       ):
         lowercase__   :       Optional[Any]				=	self.tokenizer(
             text=a						,       add_special_tokens=a						,       padding=a						,       truncation=a						,       max_length=a						,       stride=a						,       pad_to_multiple_of=a						,       return_token_type_ids=a						,       return_attention_mask=a						,       return_overflowing_tokens=a						,       return_special_tokens_mask=a						,       return_offsets_mapping=a						,       return_length=a						,       verbose=a						,       return_tensors=a						,       **a						,       )
         # add pixel_values + pixel_mask
         lowercase__   :       str				=	self.image_processor(a						,       return_tensors=a)
         encoding.update(a)

         return encoding





    def 				snake_case_    (				self						,       *a						,       **a):
         return self.tokenizer.batch_decode(*a						,       **a)





    def 				snake_case_    (				self						,       *a						,       **a):
         return self.tokenizer.decode(*a						,       **a)





    @property
    def 				snake_case_    (				self):
         lowercase__   :       int				=	self.tokenizer.model_input_names
         lowercase__   :       List[str]				=	self.image_processor.model_input_names
         return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))





    @property
    def 				snake_case_    (				self):
         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 				snake_case_    (				self):
         warnings.warn(
             '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'						,       a						,       )
         return self.image_processor

