





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer






class 						UpperCamelCase_  (  snake_case__							):
					_a      :						List[str]						    =					'Wav2Vec2FeatureExtractor'
					_a      :						Dict						    =					'AutoTokenizer'



					def __init__(		self     :     Optional[Any]       ,      lowerCamelCase     :     Union[str, Any]       ,      lowerCamelCase     :     int						):
							super().__init__(lowerCamelCase       ,      lowerCamelCase						)
							lowerCamelCase_	:     Dict 						=      self.feature_extractor
							lowerCamelCase_	:     Tuple 						=      False



					@classmethod
					def   __a     (		cls     :     List[str]       ,      lowerCamelCase     :     Optional[int]       ,      **lowerCamelCase     :     Optional[Any]						):
							try:
									return super().from_pretrained(lowerCamelCase       ,      **lowerCamelCase						)
							except OSError:
									warnings.warn(
									    F"Loading a tokenizer inside {cls.__name__} from a config that does not"
									    ' include a `tokenizer_class` attribute is deprecated and will be '
									    'removed in v5. Please add `\'tokenizer_class\': \'Wav2Vec2CTCTokenizer\'`'
									    ' attribute to either your `config.json` or `tokenizer_config.json` '
									    'file to suppress this warning: '       ,      lowerCamelCase       ,      )

									lowerCamelCase_	:     Union[str, Any] 						=      WavaVecaFeatureExtractor.from_pretrained(lowerCamelCase       ,      **lowerCamelCase						)
									lowerCamelCase_	:     Tuple 						=      WavaVecaCTCTokenizer.from_pretrained(lowerCamelCase       ,      **lowerCamelCase						)

									return cls(feature_extractor=lowerCamelCase       ,      tokenizer=lowerCamelCase						)



					def __call__(		self     :     Tuple       ,      *lowerCamelCase     :     Any       ,      **lowerCamelCase     :     Optional[Any]						):
							# For backward compatibility
							if self._in_target_context_manager:
									return self.current_processor(*lowerCamelCase       ,      **lowerCamelCase						)

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

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



					def   __a     (		self     :     str       ,      *lowerCamelCase     :     List[str]       ,      **lowerCamelCase     :     Optional[int]						):
							# For backward compatibility
							if self._in_target_context_manager:
									return self.current_processor.pad(*lowerCamelCase       ,      **lowerCamelCase						)

							lowerCamelCase_	:     Any 						=      kwargs.pop('input_features'       ,      lowerCamelCase						)
							lowerCamelCase_	:     Tuple 						=      kwargs.pop('labels'       ,      lowerCamelCase						)
							if len(lowerCamelCase						) > 0:
									lowerCamelCase_	:     List[str] 						=      args[0]
									lowerCamelCase_	:     List[Any] 						=      args[1:]

							if input_features is not None:
									lowerCamelCase_	:     str 						=      self.feature_extractor.pad(lowerCamelCase       ,      *lowerCamelCase       ,      **lowerCamelCase						)
							if labels is not None:
									lowerCamelCase_	:     List[str] 						=      self.tokenizer.pad(lowerCamelCase       ,      **lowerCamelCase						)

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



					def   __a     (		self     :     Dict       ,      *lowerCamelCase     :     Tuple       ,      **lowerCamelCase     :     Optional[Any]						):
							return self.tokenizer.batch_decode(*lowerCamelCase       ,      **lowerCamelCase						)



					def   __a     (		self     :     Union[str, Any]       ,      *lowerCamelCase     :     int       ,      **lowerCamelCase     :     int						):
							return self.tokenizer.decode(*lowerCamelCase       ,      **lowerCamelCase						)





					@contextmanager
					def   __a     (		self     :     int						):
							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_	:     Any 						=      True
							lowerCamelCase_	:     Any 						=      self.tokenizer
							yield
							lowerCamelCase_	:     List[Any] 						=      self.feature_extractor
							lowerCamelCase_	:     List[Any] 						=      False







from typing import TYPE_CHECKING

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


_lowercase		:  Dict			       ={
    """configuration_resnet""": ["""RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ResNetConfig""", """ResNetOnnxConfig"""]
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase		:  Union[str, Any]			       =[
		    """RESNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
		    """ResNetForImageClassification""",
		    """ResNetModel""",
		    """ResNetPreTrainedModel""",
		    """ResNetBackbone""",
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase		:  Union[str, Any]			       =[
		    """TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
		    """TFResNetForImageClassification""",
		    """TFResNetModel""",
		    """TFResNetPreTrainedModel""",
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase		:  Tuple			       =[
		    """FlaxResNetForImageClassification""",
		    """FlaxResNetModel""",
		    """FlaxResNetPreTrainedModel""",
		]

if TYPE_CHECKING:
		from .configuration_resnet import RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP, ResNetConfig, ResNetOnnxConfig

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_resnet import (
				    RESNET_PRETRAINED_MODEL_ARCHIVE_LIST,
				    ResNetBackbone,
				    ResNetForImageClassification,
				    ResNetModel,
				    ResNetPreTrainedModel,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_resnet import (
				    TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFResNetForImageClassification,
				    TFResNetModel,
				    TFResNetPreTrainedModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_resnet import FlaxResNetForImageClassification, FlaxResNetModel, FlaxResNetPreTrainedModel


else:
		import sys

		_lowercase		:  Union[str, Any]			       =_LazyModule(__name__, globals()["""__file__"""], _import_structure)
