






"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase_	:    Optional[Any]            =      logging.get_logger(__name__)

lowerCAmelCase_	:    Any            =      {
    '''facebook/s2t-wav2vec2-large-en-de''': (
        '''https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}





class   UpperCamelCase_ (       a_  ):
  _A       :					Dict				=	'speech_to_text_2'
  _A       :					Dict				=	['past_key_values']
  _A       :					Any				=	{'num_attention_heads': 'decoder_attention_heads', 'hidden_size': 'd_model'}



  def __init__(      self ,		snake_case__=1_00_00 ,		snake_case__=6 ,		snake_case__=20_48 ,		snake_case__=4 ,		snake_case__=0.0 ,		snake_case__=True ,		snake_case__="relu" ,		snake_case__=2_56 ,		snake_case__=0.1 ,		snake_case__=0.0 ,		snake_case__=0.0 ,		snake_case__=0.02 ,		snake_case__=2 ,		snake_case__=True ,		snake_case__=1 ,		snake_case__=0 ,		snake_case__=2 ,		snake_case__=10_24 ,		**snake_case__ ,		)			->			Optional[int]:



         """simple docstring"""





         UpperCAmelCase	    =			vocab_size
         UpperCAmelCase	    =			d_model
         UpperCAmelCase	    =			decoder_ffn_dim
         UpperCAmelCase	    =			decoder_layers
         UpperCAmelCase	    =			decoder_attention_heads
         UpperCAmelCase	    =			dropout
         UpperCAmelCase	    =			attention_dropout
         UpperCAmelCase	    =			activation_dropout
         UpperCAmelCase	    =			activation_function
         UpperCAmelCase	    =			init_std
         UpperCAmelCase	    =			decoder_layerdrop
         UpperCAmelCase	    =			use_cache
         UpperCAmelCase	    =			decoder_layers
         UpperCAmelCase	    =			scale_embedding  # scale factor will be sqrt(d_model) if True
         UpperCAmelCase	    =			max_target_positions

         super().__init__(
             pad_token_id=snake_case__ ,		bos_token_id=snake_case__ ,		eos_token_id=snake_case__ ,		decoder_start_token_id=snake_case__ ,		**snake_case__ ,		)








"""simple docstring"""







import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding





class   UpperCamelCase_ (       a_  ):
  _A       :					Optional[int]				=	['image_processor', 'tokenizer']
  _A       :					Optional[Any]				=	'ViTImageProcessor'
  _A       :					Tuple				=	('CLIPTokenizer', 'CLIPTokenizerFast')



  def __init__(      self ,		snake_case__=None ,		snake_case__=None ,		**snake_case__				)			->			Union[str, Any]:



         """simple docstring"""





         UpperCAmelCase	    =			None
         if "feature_extractor" in kwargs:
                warnings.warn(
                    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
                    """ instead.""" ,		snake_case__ ,		)
                UpperCAmelCase	    =			kwargs.pop("""feature_extractor"""				)

         UpperCAmelCase	    =			image_processor if image_processor is not None else feature_extractor
         if image_processor is None:
                raise ValueError("""You need to specify an `image_processor`."""				)
         if tokenizer is None:
                raise ValueError("""You need to specify a `tokenizer`."""				)

         super().__init__(snake_case__ ,		snake_case__				)



  def __call__(      self ,		snake_case__=None ,		snake_case__=None ,		snake_case__=None ,		snake_case__=None ,		**snake_case__				)			->			List[str]:



         """simple docstring"""





         if text is None and visual_prompt is None and images is None:
                raise ValueError("""You have to specify either text, visual prompt or images."""				)

         if text is not None and visual_prompt is not None:
                raise ValueError("""You have to specify exactly one type of prompt. Either text or visual prompt."""				)

         if text is not None:
                UpperCAmelCase	    =			self.tokenizer(snake_case__ ,		return_tensors=snake_case__ ,		**snake_case__				)

         if visual_prompt is not None:
                UpperCAmelCase	    =			self.image_processor(snake_case__ ,		return_tensors=snake_case__ ,		**snake_case__				)

         if images is not None:
                UpperCAmelCase	    =			self.image_processor(snake_case__ ,		return_tensors=snake_case__ ,		**snake_case__				)

         if visual_prompt is not None and images is not None:
                UpperCAmelCase	    =			{
                    """pixel_values""": image_features.pixel_values,
                    """conditional_pixel_values""": prompt_features.pixel_values,
                }
                return encoding
         elif text is not None and images is not None:
                UpperCAmelCase	    =			image_features.pixel_values
                return encoding
         elif text is not None:
                return encoding
         elif visual_prompt is not None:
                UpperCAmelCase	    =			{
                    """conditional_pixel_values""": prompt_features.pixel_values,
                }
                return encoding
         else:
                return BatchEncoding(data=dict(**snake_case__				) ,		tensor_type=snake_case__				)



  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			Tuple:



         """simple docstring"""





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



  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			Optional[int]:



         """simple docstring"""





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



  @property
  def 		UpperCamelCase_				(      self				)			->			Tuple:



         """simple docstring"""





         warnings.warn(
             """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.""" ,		snake_case__ ,		)
         return self.image_processor_class



  @property
  def 		UpperCamelCase_				(      self				)			->			Any:



         """simple docstring"""





         warnings.warn(
             """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.""" ,		snake_case__ ,		)
         return self.image_processor
