






import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin


class       __SCREAMING_SNAKE_CASE   (				__lowercase):
      _SCREAMING_SNAKE_CASE		:    Any						=   '''MCTCTFeatureExtractor'''
      _SCREAMING_SNAKE_CASE		:    List[str]						=   '''AutoTokenizer'''






      def __init__(		self       ,  _UpperCamelCase       ,  _UpperCamelCase				):






            """simple docstring"""
            super().__init__(_UpperCamelCase       ,  _UpperCamelCase				)
            lowerCAmelCase__        =  self.feature_extractor
            lowerCAmelCase__        =  False






      def __call__(		self       ,  *_UpperCamelCase       ,  **_UpperCamelCase				):






            """simple docstring"""
            # For backward compatibility
            if self._in_target_context_manager:
                  return self.current_processor(*_UpperCamelCase       ,  **_UpperCamelCase				)

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

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






      def  UpperCamelCase__ (		self       ,  *_UpperCamelCase       ,  **_UpperCamelCase				):






            """simple docstring"""
            return self.tokenizer.batch_decode(*_UpperCamelCase       ,  **_UpperCamelCase				)






      def  UpperCamelCase__ (		self       ,  *_UpperCamelCase       ,  **_UpperCamelCase				):






            """simple docstring"""
            # For backward compatibility
            if self._in_target_context_manager:
                  return self.current_processor.pad(*_UpperCamelCase       ,  **_UpperCamelCase				)

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

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

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






      def  UpperCamelCase__ (		self       ,  *_UpperCamelCase       ,  **_UpperCamelCase				):






            """simple docstring"""
            return self.tokenizer.decode(*_UpperCamelCase       ,  **_UpperCamelCase				)







      @contextmanager
      def  UpperCamelCase__ (		self				):






            """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.'				)
            lowerCAmelCase__        =  True
            lowerCAmelCase__        =  self.tokenizer
            yield
            lowerCAmelCase__        =  self.feature_extractor
            lowerCAmelCase__        =  False













from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__snake_case      :      Union[str, Any]             =       {
    """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ConvBertConfig""", """ConvBertOnnxConfig"""],
    """tokenization_convbert""": ["""ConvBertTokenizer"""],
}

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__snake_case      :      List[str]             =       ["""ConvBertTokenizerFast"""]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__snake_case      :      Optional[Any]             =       [
					    """CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """ConvBertForMaskedLM""",
					    """ConvBertForMultipleChoice""",
					    """ConvBertForQuestionAnswering""",
					    """ConvBertForSequenceClassification""",
					    """ConvBertForTokenClassification""",
					    """ConvBertLayer""",
					    """ConvBertModel""",
					    """ConvBertPreTrainedModel""",
					    """load_tf_weights_in_convbert""",
					]


try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__snake_case      :      Union[str, Any]             =       [
					    """TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """TFConvBertForMaskedLM""",
					    """TFConvBertForMultipleChoice""",
					    """TFConvBertForQuestionAnswering""",
					    """TFConvBertForSequenceClassification""",
					    """TFConvBertForTokenClassification""",
					    """TFConvBertLayer""",
					    """TFConvBertModel""",
					    """TFConvBertPreTrainedModel""",
					]


if TYPE_CHECKING:
					from .configuration_convbert import CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvBertConfig, ConvBertOnnxConfig
					from .tokenization_convbert import ConvBertTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_convbert_fast import ConvBertTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_convbert import (
										    CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    ConvBertForMaskedLM,
										    ConvBertForMultipleChoice,
										    ConvBertForQuestionAnswering,
										    ConvBertForSequenceClassification,
										    ConvBertForTokenClassification,
										    ConvBertLayer,
										    ConvBertModel,
										    ConvBertPreTrainedModel,
										    load_tf_weights_in_convbert,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_convbert import (
										    TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFConvBertForMaskedLM,
										    TFConvBertForMultipleChoice,
										    TFConvBertForQuestionAnswering,
										    TFConvBertForSequenceClassification,
										    TFConvBertForTokenClassification,
										    TFConvBertLayer,
										    TFConvBertModel,
										    TFConvBertPreTrainedModel,
										)


else:
					import sys

					__snake_case      :      Dict             =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





