




"""simple docstring"""

import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
class      A__   (   lowercase_  ):
	A_				:					Any      =   """AutoFeatureExtractor"""
	A_				:					Optional[int]      =   """Speech2Text2Tokenizer"""




	def __init__( self	:						Any   ,     lowercase	:						Union[str, Any]   ,     lowercase	:						Optional[int]						)       ->			Optional[Any]:
						super().__init__(lowercase   ,     lowercase						)
						__snake_case        =						self.feature_extractor
						__snake_case        =						False




	def __call__( self	:						List[Any]   ,     *lowercase	:						Tuple   ,     **lowercase	:						Optional[int]						)       ->			str:
						# For backward compatibility
						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."""						)
											__snake_case        =						kwargs.pop("""raw_speech"""						)
						else:
											__snake_case        =						kwargs.pop("""audio"""   ,     lowercase						)
						__snake_case        =						kwargs.pop("""sampling_rate"""   ,     lowercase						)
						__snake_case        =						kwargs.pop("""text"""   ,     lowercase						)
						if len(lowercase						) > 0:
											__snake_case        =						args[0]
											__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:
											__snake_case        =						self.feature_extractor(lowercase   ,     *lowercase   ,     sampling_rate=lowercase   ,     **lowercase						)
						if text is not None:
											__snake_case        =						self.tokenizer(lowercase   ,     **lowercase						)

						if text is None:
											return inputs
						elif audio is None:
											return encodings
						else:
											__snake_case        =						encodings["""input_ids"""]
											return inputs




	def 				a_		( self	:						Union[str, Any]   ,     *lowercase	:						Optional[int]   ,     **lowercase	:						List[str]						)       ->			Dict:
						return self.tokenizer.batch_decode(*lowercase   ,     **lowercase						)




	def 				a_		( self	:						Optional[int]   ,     *lowercase	:						List[str]   ,     **lowercase	:						Any						)       ->			List[str]:
						return self.tokenizer.decode(*lowercase   ,     **lowercase						)




	@contextmanager
	def 				a_		( self	:						List[str]						)       ->			List[str]:
						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."""						)
						__snake_case        =						True
						__snake_case        =						self.tokenizer
						yield
						__snake_case        =						self.feature_extractor
						__snake_case        =						False








"""simple docstring"""

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


UpperCamelCase__			:     Optional[Any]			       =				logging.get_logger(__name__)
class      A__   (   lowercase_  ):
	A_				:					List[str]      =   """vision-text-dual-encoder"""
	A_				:					Tuple      =   True




	def __init__( self	:						Tuple   ,     lowercase	:						List[Any]=512   ,     lowercase	:						Any=2.65_92   ,     **lowercase	:						int						)       ->			int:
						super().__init__(**lowercase						)

						if "vision_config" not in kwargs:
											raise ValueError("""`vision_config` can not be `None`."""						)

						if "text_config" not in kwargs:
											raise ValueError("""`text_config` can not be `None`."""						)

						__snake_case        =						kwargs.pop("""vision_config"""						)
						__snake_case        =						kwargs.pop("""text_config"""						)

						__snake_case        =						vision_config.pop("""model_type"""						)
						__snake_case        =						text_config.pop("""model_type"""						)

						if vision_model_type == "clip":
											__snake_case        =						AutoConfig.for_model(lowercase   ,     **lowercase						).vision_config
						elif vision_model_type == "clip_vision_model":
											__snake_case        =						CLIPVisionConfig(**lowercase						)
						else:
											__snake_case        =						AutoConfig.for_model(lowercase   ,     **lowercase						)

						__snake_case        =						AutoConfig.for_model(lowercase   ,     **lowercase						)

						__snake_case        =						projection_dim
						__snake_case        =						logit_scale_init_value




	@classmethod
	def 				a_		( cls	:						Union[str, Any]   ,     lowercase	:						PretrainedConfig   ,     lowercase	:						PretrainedConfig   ,     **lowercase	:						Optional[int]						)       ->			Dict:
						return cls(vision_config=vision_config.to_dict()   ,     text_config=text_config.to_dict()   ,     **lowercase						)




	def 				a_		( self	:						Dict						)       ->			Dict:
						__snake_case        =						copy.deepcopy(self.__dict__						)
						__snake_case        =						self.vision_config.to_dict()
						__snake_case        =						self.text_config.to_dict()
						__snake_case        =						self.__class__.model_type
						return output


