



"""simple docstring"""
from ...processing_utils import ProcessorMixin






class  _SCREAMING_SNAKE_CASE(       __snake_case  ):
       SCREAMING_SNAKE_CASE_       :				List[str]     						=  'SpeechT5FeatureExtractor'
       SCREAMING_SNAKE_CASE_       :				str     						=  'SpeechT5Tokenizer'




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)      ->				int:





             """simple docstring"""






             super().__init__(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)




       def __call__(						self		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :str		    =  kwargs.pop('''audio'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  kwargs.pop('''text'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :Dict		    =  kwargs.pop('''text_target'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  kwargs.pop('''audio_target'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :int		    =  kwargs.pop('''sampling_rate'''		,SCREAMING_SNAKE_CASE__							)

             if audio is not None and text is not None:
                   raise ValueError(
                       '''Cannot process both `audio` and `text` inputs. Did you mean `audio_target` or `text_target`?'''							)
             if audio_target is not None and text_target is not None:
                   raise ValueError(
                       '''Cannot process both `audio_target` and `text_target` inputs. Did you mean `audio` or `text`?'''							)
             if audio is None and audio_target is None and text is None and text_target is None:
                   raise ValueError(
                       '''You need to specify either an `audio`, `audio_target`, `text`, or `text_target` input to process.'''							)

             if audio is not None:
                   __SCREAMING_SNAKE_CASE       :Dict		    =  self.feature_extractor(SCREAMING_SNAKE_CASE__		,*SCREAMING_SNAKE_CASE__		,sampling_rate=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
             elif text is not None:
                   __SCREAMING_SNAKE_CASE       :Dict		    =  self.tokenizer(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
             else:
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  None

             if audio_target is not None:
                   __SCREAMING_SNAKE_CASE       :Dict		    =  self.feature_extractor(audio_target=SCREAMING_SNAKE_CASE__		,*SCREAMING_SNAKE_CASE__		,sampling_rate=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  targets['''input_values''']
             elif text_target is not None:
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  self.tokenizer(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  targets['''input_ids''']
             else:
                   __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  None

             if inputs is None:
                   return targets

             if targets is not None:
                   __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  labels

                   __SCREAMING_SNAKE_CASE       :str		    =  targets.get('''attention_mask'''							)
                   if decoder_attention_mask is not None:
                         __SCREAMING_SNAKE_CASE       :List[Any]		    =  decoder_attention_mask

             return inputs




       def    _UpperCamelCase					(						self		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  kwargs.pop('''input_values'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :List[str]		    =  kwargs.pop('''input_ids'''		,SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :Any		    =  kwargs.pop('''labels'''		,SCREAMING_SNAKE_CASE__							)

             if input_values is not None and input_ids is not None:
                   raise ValueError('''Cannot process both `input_values` and `input_ids` inputs.'''							)
             if input_values is None and input_ids is None and labels is None:
                   raise ValueError(
                       '''You need to specify either an `input_values`, `input_ids`, or `labels` input to be padded.'''							)

             if input_values is not None:
                   __SCREAMING_SNAKE_CASE       :Tuple		    =  self.feature_extractor.pad(SCREAMING_SNAKE_CASE__		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
             elif input_ids is not None:
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  self.tokenizer.pad(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
             else:
                   __SCREAMING_SNAKE_CASE       :Tuple		    =  None

             if labels is not None:
                   if "input_ids" in labels or (isinstance(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							) and "input_ids" in labels[0]):
                         __SCREAMING_SNAKE_CASE       :Dict		    =  self.tokenizer.pad(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
                         __SCREAMING_SNAKE_CASE       :Tuple		    =  targets['''input_ids''']
                   else:
                         __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  self.feature_extractor.feature_size
                         __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  self.feature_extractor.num_mel_bins
                         __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  self.feature_extractor.pad(SCREAMING_SNAKE_CASE__		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)
                         __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  feature_size_hack
                         __SCREAMING_SNAKE_CASE       :Any		    =  targets['''input_values''']
             else:
                   __SCREAMING_SNAKE_CASE       :Dict		    =  None

             if inputs is None:
                   return targets

             if targets is not None:
                   __SCREAMING_SNAKE_CASE       :Tuple		    =  labels

                   __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  targets.get('''attention_mask'''							)
                   if decoder_attention_mask is not None:
                         __SCREAMING_SNAKE_CASE       :List[Any]		    =  decoder_attention_mask

             return inputs




       def    _UpperCamelCase					(						self		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				int:





             """simple docstring"""






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




       def    _UpperCamelCase					(						self		,*SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				Optional[int]:





             """simple docstring"""






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






"""simple docstring"""
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase_       =		logging.get_logger(__name__)

lowerCamelCase_       =		{
    "facebook/levit-128S": "https://huggingface.co/facebook/levit-128S/resolve/main/config.json",
    # See all LeViT models at https://huggingface.co/models?filter=levit
}






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				List[Any]     						=  '''levit'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=2_24		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=16		,SCREAMING_SNAKE_CASE__=[1_28, 2_56, 3_84]		,SCREAMING_SNAKE_CASE__=[4, 8, 12]		,SCREAMING_SNAKE_CASE__=[4, 4, 4]		,SCREAMING_SNAKE_CASE__=[16, 16, 16]		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=[2, 2, 2]		,SCREAMING_SNAKE_CASE__=[2, 2, 2]		,SCREAMING_SNAKE_CASE__=0.0_2		,**SCREAMING_SNAKE_CASE__		,)      ->				Tuple:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :Dict		    =  image_size
             __SCREAMING_SNAKE_CASE       :Dict		    =  num_channels
             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  kernel_size
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  stride
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  padding
             __SCREAMING_SNAKE_CASE       :Tuple		    =  hidden_sizes
             __SCREAMING_SNAKE_CASE       :List[str]		    =  num_attention_heads
             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  depths
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  key_dim
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  drop_path_rate
             __SCREAMING_SNAKE_CASE       :Tuple		    =  patch_size
             __SCREAMING_SNAKE_CASE       :int		    =  attention_ratio
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  mlp_ratio
             __SCREAMING_SNAKE_CASE       :str		    =  initializer_range
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  [
                 ['''Subsample''', key_dim[0], hidden_sizes[0] // key_dim[0], 4, 2, 2],
                 ['''Subsample''', key_dim[0], hidden_sizes[1] // key_dim[0], 4, 2, 2],
             ]






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				int     						=  version.parse('''1.11'''  )




       @property
       def    _UpperCamelCase					(						self							)      ->				Mapping[str, Mapping[int, str]]:





             """simple docstring"""






             return OrderedDict(
                 [
                     ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
                 ]							)




       @property
       def    _UpperCamelCase					(						self							)      ->				float:





             """simple docstring"""






             return 1E-4