
'''simple docstring'''




from typing import List, Optional

import numpy as np

from ...processing_utils import ProcessorMixin
from ...utils import to_numpy





class  A				(							__snake_case						):
     __magic_name__						=		'''EncodecFeatureExtractor'''
     __magic_name__						=		('''T5Tokenizer''', '''T5TokenizerFast''')





     def __init__(							self						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	) ->				Optional[int]:






         """simple docstring"""






         super().__init__(SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	)
         A       :   List[Any]					=						self.feature_extractor
         A       :   Union[str, Any]					=						False





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE=None						,			SCREAMING_SNAKE_CASE=None						,			SCREAMING_SNAKE_CASE=True	) ->				Tuple:






         """simple docstring"""






         return self.tokenizer.get_decoder_prompt_ids(task=SCREAMING_SNAKE_CASE						,			language=SCREAMING_SNAKE_CASE						,			no_timestamps=SCREAMING_SNAKE_CASE	)





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






         """simple docstring"""






         if self._in_target_context_manager:
             return self.current_processor(*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	)

         A       :   Any					=						kwargs.pop('''audio'''						,			SCREAMING_SNAKE_CASE	)
         A       :   Optional[int]					=						kwargs.pop('''sampling_rate'''						,			SCREAMING_SNAKE_CASE	)
         A       :   Any					=						kwargs.pop('''text'''						,			SCREAMING_SNAKE_CASE	)
         if len(SCREAMING_SNAKE_CASE	) > 0:
             A       :   List[Any]					=						args[0]
             A       :   Dict					=						args[1:]

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

         if text is not None:
             A       :   Tuple					=						self.tokenizer(SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	)

         if audio is not None:
             A       :   List[str]					=						self.feature_extractor(SCREAMING_SNAKE_CASE						,			*SCREAMING_SNAKE_CASE						,			sampling_rate=SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	)

         if audio is None:
             return inputs

         elif text is None:
             return audio_inputs

         else:
             A       :   Optional[Any]					=						audio_inputs['''input_values''']
             if "padding_mask" in audio_inputs:
                 A       :   Optional[int]					=						audio_inputs['''padding_mask''']
             return inputs





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				int:






         """simple docstring"""






         A       :   Optional[Any]					=						kwargs.pop('''audio'''						,			SCREAMING_SNAKE_CASE	)
         A       :   Optional[int]					=						kwargs.pop('''padding_mask'''						,			SCREAMING_SNAKE_CASE	)

         if len(SCREAMING_SNAKE_CASE	) > 0:
             A       :   List[str]					=						args[0]
             A       :   Union[str, Any]					=						args[1:]

         if audio_values is not None:
             return self._decode_audio(SCREAMING_SNAKE_CASE						,			padding_mask=SCREAMING_SNAKE_CASE	)
         else:
             return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	)





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				Dict:






         """simple docstring"""






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





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE = None	) ->				List[np.ndarray]:






         """simple docstring"""






         A       :   Tuple					=						to_numpy(SCREAMING_SNAKE_CASE	)
         A,  A,  A       :   Union[str, Any]					=						audio_values.shape

         if padding_mask is None:
             return list(SCREAMING_SNAKE_CASE	)

         A       :   List[str]					=						to_numpy(SCREAMING_SNAKE_CASE	)

         # match the sequence length of the padding mask to the generated audio arrays by padding with the **non-padding**
         # token (so that the generated audio values are **not** treated as padded tokens)
         A       :   Any					=						seq_len - padding_mask.shape[-1]
         A       :   List[Any]					=						1 - self.feature_extractor.padding_value
         A       :   Tuple					=						np.pad(SCREAMING_SNAKE_CASE						,			((0, 0), (0, difference))						,			'''constant'''						,			constant_values=SCREAMING_SNAKE_CASE	)

         A       :   Union[str, Any]					=						audio_values.tolist()
         for i in range(SCREAMING_SNAKE_CASE	):
             A       :   Tuple					=						np.asarray(audio_values[i]	)[
                 padding_mask[i][None, :] != self.feature_extractor.padding_value
             ]
             A       :   Any					=						sliced_audio.reshape(SCREAMING_SNAKE_CASE						,			-1	)

         return audio_values






'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

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


lowercase			:				Union[str, Any]    		=			logging.get_logger(__name__)

lowercase			:				str    		=			{
    'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/config.json',
    'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/config.json',
    'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/config.json',
    'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/config.json',
    'bert-base-multilingual-uncased': 'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json',
    'bert-base-multilingual-cased': 'https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json',
    'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/config.json',
    'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/config.json',
    'bert-large-uncased-whole-word-masking': (
        'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json'
    ),
    'bert-large-cased-whole-word-masking': (
        'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json'
    ),
    'bert-large-uncased-whole-word-masking-finetuned-squad': (
        'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json'
    ),
    'bert-large-cased-whole-word-masking-finetuned-squad': (
        'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json'
    ),
    'bert-base-cased-finetuned-mrpc': 'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json',
    'bert-base-german-dbmdz-cased': 'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json',
    'bert-base-german-dbmdz-uncased': 'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json',
    'cl-tohoku/bert-base-japanese': 'https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json',
    'cl-tohoku/bert-base-japanese-whole-word-masking': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json'
    ),
    'cl-tohoku/bert-base-japanese-char': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json'
    ),
    'cl-tohoku/bert-base-japanese-char-whole-word-masking': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json'
    ),
    'TurkuNLP/bert-base-finnish-cased-v1': (
        'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json'
    ),
    'TurkuNLP/bert-base-finnish-uncased-v1': (
        'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json'
    ),
    'wietsedv/bert-base-dutch-cased': 'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json',
    # See all BERT models at https://huggingface.co/models?filter=bert
}





class  A				(							__snake_case						):
     __magic_name__						=		'''bert'''





     def __init__(							self						,			SCREAMING_SNAKE_CASE=30522						,			SCREAMING_SNAKE_CASE=768						,			SCREAMING_SNAKE_CASE=12						,			SCREAMING_SNAKE_CASE=12						,			SCREAMING_SNAKE_CASE=3072						,			SCREAMING_SNAKE_CASE="gelu"						,			SCREAMING_SNAKE_CASE=0.1						,			SCREAMING_SNAKE_CASE=0.1						,			SCREAMING_SNAKE_CASE=512						,			SCREAMING_SNAKE_CASE=2						,			SCREAMING_SNAKE_CASE=0.02						,			SCREAMING_SNAKE_CASE=1e-12						,			SCREAMING_SNAKE_CASE=0						,			SCREAMING_SNAKE_CASE="absolute"						,			SCREAMING_SNAKE_CASE=True						,			SCREAMING_SNAKE_CASE=None						,			**SCREAMING_SNAKE_CASE						,			) ->				Optional[int]:






         """simple docstring"""






         super().__init__(pad_token_id=SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	)

         A       :   Optional[int]					=						vocab_size
         A       :   Optional[Any]					=						hidden_size
         A       :   List[Any]					=						num_hidden_layers
         A       :   List[str]					=						num_attention_heads
         A       :   Dict					=						hidden_act
         A       :   Optional[Any]					=						intermediate_size
         A       :   List[Any]					=						hidden_dropout_prob
         A       :   List[Any]					=						attention_probs_dropout_prob
         A       :   Optional[Any]					=						max_position_embeddings
         A       :   List[str]					=						type_vocab_size
         A       :   Dict					=						initializer_range
         A       :   str					=						layer_norm_eps
         A       :   int					=						position_embedding_type
         A       :   Dict					=						use_cache
         A       :   str					=						classifier_dropout





class  A				(							__snake_case						):





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






         """simple docstring"""






         if self.task == "multiple-choice":
             A       :   Optional[Any]					=						{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
         else:
             A       :   Optional[int]					=						{0: '''batch''', 1: '''sequence'''}
         return OrderedDict(
             [
                 ('''input_ids''', dynamic_axis),
                 ('''attention_mask''', dynamic_axis),
                 ('''token_type_ids''', dynamic_axis),
             ]	)




