

"""simple docstring"""




from ...processing_utils import ProcessorMixin





class    lowerCamelCase						(A__			):
			lowerCamelCase__   :		Union[str, Any]							=							'SpeechT5FeatureExtractor'
			lowerCamelCase__   :		Optional[int]							=							'SpeechT5Tokenizer'

			def __init__(					self				:						str    ,				__UpperCAmelCase				:						Optional[int]    ,				__UpperCAmelCase				:						Tuple       )   ->    List[Any]:
						super().__init__(__UpperCAmelCase    ,				__UpperCAmelCase       )

			def __call__(					self				:						int    ,				*__UpperCAmelCase				:						Dict    ,				**__UpperCAmelCase				:						Dict       )   ->    Any:
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""audio"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""text"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""text_target"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""audio_target"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""sampling_rate"""    ,				__UpperCAmelCase       )

						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__								=      self.feature_extractor(__UpperCAmelCase    ,				*__UpperCAmelCase    ,				sampling_rate=__UpperCAmelCase    ,				**__UpperCAmelCase       )
						elif text is not None:
									SCREAMING_SNAKE_CASE__								=      self.tokenizer(__UpperCAmelCase    ,				**__UpperCAmelCase       )
						else:
									SCREAMING_SNAKE_CASE__								=      None

						if audio_target is not None:
									SCREAMING_SNAKE_CASE__								=      self.feature_extractor(audio_target=__UpperCAmelCase    ,				*__UpperCAmelCase    ,				sampling_rate=__UpperCAmelCase    ,				**__UpperCAmelCase       )
									SCREAMING_SNAKE_CASE__								=      targets["""input_values"""]
						elif text_target is not None:
									SCREAMING_SNAKE_CASE__								=      self.tokenizer(__UpperCAmelCase    ,				**__UpperCAmelCase       )
									SCREAMING_SNAKE_CASE__								=      targets["""input_ids"""]
						else:
									SCREAMING_SNAKE_CASE__								=      None

						if inputs is None:
									return targets

						if targets is not None:
									SCREAMING_SNAKE_CASE__								=      labels

									SCREAMING_SNAKE_CASE__								=      targets.get("""attention_mask"""       )
									if decoder_attention_mask is not None:
												SCREAMING_SNAKE_CASE__								=      decoder_attention_mask

						return inputs

			def 					SCREAMING_SNAKE_CASE				(					self				:						int    ,				*__UpperCAmelCase				:						Optional[int]    ,				**__UpperCAmelCase				:						int       )   ->    Optional[Any]:
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""input_values"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""input_ids"""    ,				__UpperCAmelCase       )
						SCREAMING_SNAKE_CASE__								=      kwargs.pop("""labels"""    ,				__UpperCAmelCase       )

						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__								=      self.feature_extractor.pad(__UpperCAmelCase    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase       )
						elif input_ids is not None:
									SCREAMING_SNAKE_CASE__								=      self.tokenizer.pad(__UpperCAmelCase    ,				**__UpperCAmelCase       )
						else:
									SCREAMING_SNAKE_CASE__								=      None

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

						if inputs is None:
									return targets

						if targets is not None:
									SCREAMING_SNAKE_CASE__								=      labels

									SCREAMING_SNAKE_CASE__								=      targets.get("""attention_mask"""       )
									if decoder_attention_mask is not None:
												SCREAMING_SNAKE_CASE__								=      decoder_attention_mask

						return inputs

			def 					SCREAMING_SNAKE_CASE				(					self				:						Union[str, Any]    ,				*__UpperCAmelCase				:						int    ,				**__UpperCAmelCase				:						Union[str, Any]       )   ->    List[str]:
						return self.tokenizer.batch_decode(*__UpperCAmelCase    ,				**__UpperCAmelCase       )





			def 					SCREAMING_SNAKE_CASE				(					self				:						Optional[int]    ,				*__UpperCAmelCase				:						Union[str, Any]    ,				**__UpperCAmelCase				:						Dict       )   ->    Union[str, Any]:
						return self.tokenizer.decode(*__UpperCAmelCase    ,				**__UpperCAmelCase       )





"""simple docstring"""




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A_							:			Dict											= {
    "configuration_efficientnet": [
        "EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "EfficientNetConfig",
        "EfficientNetOnnxConfig",
    ]
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_							:			List[Any]											= ["EfficientNetImageProcessor"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_							:			Dict											= [
						    "EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "EfficientNetForImageClassification",
						    "EfficientNetModel",
						    "EfficientNetPreTrainedModel",
						]

if TYPE_CHECKING:
						from .configuration_efficientnet import (
						    EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    EfficientNetConfig,
						    EfficientNetOnnxConfig,
						)

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .image_processing_efficientnet import EfficientNetImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_efficientnet import (
												    EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST,
												    EfficientNetForImageClassification,
												    EfficientNetModel,
												    EfficientNetPreTrainedModel,
												)

else:
						import sys

						A_							:			List[Any]											= _LazyModule(__name__, globals()["__file__"], _import_structure)


