



'''simple docstring'''





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


_UpperCamelCase											=		logging.get_logger(__name__)

_UpperCamelCase											=		{
    'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json',
    # See all CANINE models at https://huggingface.co/models?filter=canine
}






class    lowerCamelCase_       (							__lowerCamelCase	):
  """simple docstring"""




  a_				   ='canine'




  def __init__(					self :      Optional[Any]     ,      _a :      Optional[Any]=768     ,      _a :      Union[str, Any]=12     ,      _a :      Dict=12     ,      _a :      Tuple=3072     ,      _a :      str="gelu"     ,      _a :      Optional[int]=0.1     ,      _a :      Optional[int]=0.1     ,      _a :      Dict=1_6384     ,      _a :      Tuple=16     ,      _a :      Any=0.02     ,      _a :      int=1e-12     ,      _a :      Tuple=0     ,      _a :      int=0Xe_000     ,      _a :      Optional[Any]=0Xe_001     ,      _a :      Optional[Any]=4     ,      _a :      int=4     ,      _a :      str=8     ,      _a :      Union[str, Any]=1_6384     ,      _a :      List[Any]=128     ,      **_a :      Optional[int]     ,      )   ->   Optional[int]:
    super().__init__(pad_token_id=_a     ,      bos_token_id=_a     ,      eos_token_id=_a     ,      **_a  )

    __lowerCamelCase			:			Tuple       			=					max_position_embeddings
    __lowerCamelCase			:			Optional[Any]       			=					hidden_size
    __lowerCamelCase			:			Union[str, Any]       			=					num_hidden_layers
    __lowerCamelCase			:			Optional[int]       			=					num_attention_heads
    __lowerCamelCase			:			Union[str, Any]       			=					intermediate_size
    __lowerCamelCase			:			Tuple       			=					hidden_act
    __lowerCamelCase			:			str       			=					hidden_dropout_prob
    __lowerCamelCase			:			Union[str, Any]       			=					attention_probs_dropout_prob
    __lowerCamelCase			:			List[Any]       			=					initializer_range
    __lowerCamelCase			:			Tuple       			=					type_vocab_size
    __lowerCamelCase			:			List[str]       			=					layer_norm_eps

    # Character config:
    __lowerCamelCase			:			List[Any]       			=					downsampling_rate
    __lowerCamelCase			:			Optional[Any]       			=					upsampling_kernel_size
    __lowerCamelCase			:			Any       			=					num_hash_functions
    __lowerCamelCase			:			Optional[int]       			=					num_hash_buckets
    __lowerCamelCase			:			Tuple       			=					local_transformer_stride








import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin





class     lowerCamelCase      (       __lowerCamelCase					):
	UpperCamelCase_  :					Optional[Any]    		=	'MCTCTFeatureExtractor'
	UpperCamelCase_  :					List[Any]    		=	'AutoTokenizer'







	def __init__(     self      :Tuple   ,     lowercase      :List[str]   ,     lowercase      :Dict			)		->      Tuple:







				"""simple docstring"""






				super().__init__(lowercase   ,     lowercase			)
				SCREAMING_SNAKE_CASE     						= self.feature_extractor
				SCREAMING_SNAKE_CASE     						= False







	def __call__(     self      :Union[str, Any]   ,     *lowercase      :Union[str, Any]   ,     **lowercase      :str			)		->      int:







				"""simple docstring"""






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

				if "raw_speech" in kwargs:
							warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''			)
							SCREAMING_SNAKE_CASE     						= kwargs.pop('''raw_speech'''			)
				else:
							SCREAMING_SNAKE_CASE     						= kwargs.pop('''audio'''   ,     lowercase			)
				SCREAMING_SNAKE_CASE     						= kwargs.pop('''sampling_rate'''   ,     lowercase			)
				SCREAMING_SNAKE_CASE     						= kwargs.pop('''text'''   ,     lowercase			)
				if len(lowercase			) > 0:
							SCREAMING_SNAKE_CASE     						= args[0]
							SCREAMING_SNAKE_CASE     						= 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 audio is not None:
							SCREAMING_SNAKE_CASE     						= self.feature_extractor(lowercase   ,     *lowercase   ,     sampling_rate=lowercase   ,     **lowercase			)
				if text is not None:
							SCREAMING_SNAKE_CASE     						= self.tokenizer(lowercase   ,     **lowercase			)

				if text is None:
							return inputs
				elif audio is None:
							return encodings
				else:
							SCREAMING_SNAKE_CASE     						= encodings['''input_ids''']
							return inputs







	def  snake_case__     (     self      :Dict   ,     *lowercase      :Union[str, Any]   ,     **lowercase      :List[str]			)		->      Union[str, Any]:







				"""simple docstring"""






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







	def  snake_case__     (     self      :List[Any]   ,     *lowercase      :List[Any]   ,     **lowercase      :List[str]			)		->      int:







				"""simple docstring"""






				if self._in_target_context_manager:
							return self.current_processor.pad(*lowercase   ,     **lowercase			)

				SCREAMING_SNAKE_CASE     						= kwargs.pop('''input_features'''   ,     lowercase			)
				SCREAMING_SNAKE_CASE     						= kwargs.pop('''labels'''   ,     lowercase			)
				if len(lowercase			) > 0:
							SCREAMING_SNAKE_CASE     						= args[0]
							SCREAMING_SNAKE_CASE     						= args[1:]

				if input_features is not None:
							SCREAMING_SNAKE_CASE     						= self.feature_extractor.pad(lowercase   ,     *lowercase   ,     **lowercase			)
				if labels is not None:
							SCREAMING_SNAKE_CASE     						= self.tokenizer.pad(lowercase   ,     **lowercase			)

				if labels is None:
							return input_features
				elif input_features is None:
							return labels
				else:
							SCREAMING_SNAKE_CASE     						= labels['''input_ids''']
							return input_features







	def  snake_case__     (     self      :Dict   ,     *lowercase      :List[str]   ,     **lowercase      :Union[str, Any]			)		->      List[Any]:







				"""simple docstring"""






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







	@contextmanager
	def  snake_case__     (     self      :str			)		->      Union[str, Any]:







				"""simple docstring"""






				warnings.warn(
				    '''`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '''
				    '''labels by using the argument `text` of the regular `__call__` method (either in the same call as '''
				    '''your audio inputs, or in a separate call.'''			)
				SCREAMING_SNAKE_CASE     						= True
				SCREAMING_SNAKE_CASE     						= self.tokenizer
				yield
				SCREAMING_SNAKE_CASE     						= self.feature_extractor
				SCREAMING_SNAKE_CASE     						= False