


from ...processing_utils import ProcessorMixin



class 				_UpperCamelCase			(    _a    ):

   '''simple docstring'''







   a_					:				Optional[int]     =			'''SpeechT5FeatureExtractor'''
   a_					:				List[Any]     =			'''SpeechT5Tokenizer'''

   def __init__(	self	:			Union[str, Any]							,	_lowerCamelCase	:			Optional[Any]							,	_lowerCamelCase	:			int				):






         '''simple docstring'''



         super().__init__(__UpperCamelCase							,	__UpperCamelCase				)

   def __call__(	self	:			Dict							,	*_lowerCamelCase	:			int							,	**_lowerCamelCase	:			Any				):






         '''simple docstring'''



         __lowerCamelCase  :   str							    =    kwargs.pop("""audio"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   str							    =    kwargs.pop("""text"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   Union[str, Any]							    =    kwargs.pop("""text_target"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   Any							    =    kwargs.pop("""audio_target"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   int							    =    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:
               __lowerCamelCase  :   Dict							    =    self.feature_extractor(__UpperCamelCase							,	*__UpperCamelCase							,	sampling_rate=__UpperCamelCase							,	**__UpperCamelCase				)
         elif text is not None:
               __lowerCamelCase  :   Optional[int]							    =    self.tokenizer(__UpperCamelCase							,	**__UpperCamelCase				)
         else:
               __lowerCamelCase  :   str							    =    None

         if audio_target is not None:
               __lowerCamelCase  :   int							    =    self.feature_extractor(audio_target=__UpperCamelCase							,	*__UpperCamelCase							,	sampling_rate=__UpperCamelCase							,	**__UpperCamelCase				)
               __lowerCamelCase  :   Optional[Any]							    =    targets["""input_values"""]
         elif text_target is not None:
               __lowerCamelCase  :   Dict							    =    self.tokenizer(__UpperCamelCase							,	**__UpperCamelCase				)
               __lowerCamelCase  :   str							    =    targets["""input_ids"""]
         else:
               __lowerCamelCase  :   List[str]							    =    None

         if inputs is None:
               return targets

         if targets is not None:
               __lowerCamelCase  :   Optional[Any]							    =    labels

               __lowerCamelCase  :   Optional[int]							    =    targets.get("""attention_mask"""				)
               if decoder_attention_mask is not None:
                     __lowerCamelCase  :   Tuple							    =    decoder_attention_mask

         return inputs

   def 	_snake_case     (	self	:			Tuple							,	*_lowerCamelCase	:			Union[str, Any]							,	**_lowerCamelCase	:			List[Any]				):






         '''simple docstring'''



         __lowerCamelCase  :   List[str]							    =    kwargs.pop("""input_values"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   Optional[int]							    =    kwargs.pop("""input_ids"""							,	__UpperCamelCase				)
         __lowerCamelCase  :   Optional[Any]							    =    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:
               __lowerCamelCase  :   List[Any]							    =    self.feature_extractor.pad(__UpperCamelCase							,	*__UpperCamelCase							,	**__UpperCamelCase				)
         elif input_ids is not None:
               __lowerCamelCase  :   Union[str, Any]							    =    self.tokenizer.pad(__UpperCamelCase							,	**__UpperCamelCase				)
         else:
               __lowerCamelCase  :   List[str]							    =    None

         if labels is not None:
               if "input_ids" in labels or (isinstance(__UpperCamelCase							,	__UpperCamelCase				) and "input_ids" in labels[0]):
                     __lowerCamelCase  :   Optional[Any]							    =    self.tokenizer.pad(__UpperCamelCase							,	**__UpperCamelCase				)
                     __lowerCamelCase  :   Union[str, Any]							    =    targets["""input_ids"""]
               else:
                     __lowerCamelCase  :   Union[str, Any]							    =    self.feature_extractor.feature_size
                     __lowerCamelCase  :   Tuple							    =    self.feature_extractor.num_mel_bins
                     __lowerCamelCase  :   int							    =    self.feature_extractor.pad(__UpperCamelCase							,	*__UpperCamelCase							,	**__UpperCamelCase				)
                     __lowerCamelCase  :   Tuple							    =    feature_size_hack
                     __lowerCamelCase  :   List[str]							    =    targets["""input_values"""]
         else:
               __lowerCamelCase  :   Optional[Any]							    =    None

         if inputs is None:
               return targets

         if targets is not None:
               __lowerCamelCase  :   List[str]							    =    labels

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

         return inputs

   def 	_snake_case     (	self	:			Tuple							,	*_lowerCamelCase	:			Any							,	**_lowerCamelCase	:			int				):






         '''simple docstring'''



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


   def 	_snake_case     (	self	:			Optional[int]							,	*_lowerCamelCase	:			Dict							,	**_lowerCamelCase	:			Any				):






         '''simple docstring'''



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





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


A		: Dict								=     {
    '''configuration_x_clip''': [
        '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''XCLIPConfig''',
        '''XCLIPTextConfig''',
        '''XCLIPVisionConfig''',
    ],
    '''processing_x_clip''': ['''XCLIPProcessor'''],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A		: Optional[Any]								=     [
		    '''XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''XCLIPModel''',
		    '''XCLIPPreTrainedModel''',
		    '''XCLIPTextModel''',
		    '''XCLIPVisionModel''',
		]

if TYPE_CHECKING:
		from .configuration_x_clip import (
		    XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    XCLIPConfig,
		    XCLIPTextConfig,
		    XCLIPVisionConfig,
		)
		from .processing_x_clip import XCLIPProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_x_clip import (
				    XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
				    XCLIPModel,
				    XCLIPPreTrainedModel,
				    XCLIPTextModel,
				    XCLIPVisionModel,
				)

else:
		import sys

		A		: List[str]								=     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)