




import warnings

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




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    lowerCamelCase_				:     Tuple     					=				["image_processor", "tokenizer"]
    lowerCamelCase_				:     Optional[Any]     					=				"VideoMAEImageProcessor"
    lowerCamelCase_				:     str     					=				("CLIPTokenizer", "CLIPTokenizerFast")







    def __init__(   self					,  UpperCamelCase__=None					,  UpperCamelCase__=None					,  **UpperCamelCase__					)					->				Tuple:
           lowerCamelCase       :				Optional[int]      			= None
           if "feature_extractor" in kwargs:
                  warnings.warn(
                      "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                      " instead."					,  lowercase__					,  )
                  lowerCamelCase       :				Any      			= kwargs.pop("feature_extractor"					)

           lowerCamelCase       :				int      			= 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__(lowercase__					,  lowercase__					)
           lowerCamelCase       :				Optional[int]      			= self.image_processor







    def __call__(   self					,  UpperCamelCase__=None					,  UpperCamelCase__=None					,  UpperCamelCase__=None					,  **UpperCamelCase__					)					->				Optional[Any]:







           if text is None and videos is None:
                  raise ValueError("You have to specify either text or videos. Both cannot be none."					)

           if text is not None:
                  lowerCamelCase       :				Tuple      			= self.tokenizer(lowercase__					,  return_tensors=lowercase__					,  **lowercase__					)

           if videos is not None:
                  lowerCamelCase       :				int      			= self.image_processor(lowercase__					,  return_tensors=lowercase__					,  **lowercase__					)

           if text is not None and videos is not None:
                  lowerCamelCase       :				Dict      			= image_features.pixel_values
                  return encoding
           elif text is not None:
                  return encoding
           else:
                  return BatchEncoding(data=dict(**lowercase__					)					,  tensor_type=lowercase__					)







    def    _lowercase					(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				str:
           return self.tokenizer.batch_decode(*lowercase__					,  **lowercase__					)







    def    _lowercase					(   self					,  *UpperCamelCase__					,  **UpperCamelCase__					)					->				Optional[Any]:
           return self.tokenizer.decode(*lowercase__					,  **lowercase__					)







    @property
    def    _lowercase					(   self					)					->				Dict:
           return ["input_ids", "attention_mask", "position_ids", "pixel_values"]







    @property
    def    _lowercase					(   self					)					->				List[Any]:
           warnings.warn(
               "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."					,  lowercase__					,  )
           return self.image_processor_class







    @property
    def    _lowercase					(   self					)					->				Optional[Any]:
           warnings.warn(
               "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."					,  lowercase__					,  )
           return self.image_processor












import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


SCREAMING_SNAKE_CASE__	:				int  =       logging.get_logger(__name__)




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    lowerCamelCase_				:     str     					=				"""speech-encoder-decoder"""
    lowerCamelCase_				:     List[str]     					=				True







    def __init__(   self					,  **UpperCamelCase__					)					->				Dict:
           super().__init__(**UpperCamelCase__					)
           if "encoder" not in kwargs or "decoder" not in kwargs:
                  raise ValueError(
                      F'''A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and'''
                      F''' `decoder` sub-configurations are passed, but only {kwargs}'''					)

           lowerCamelCase       :				Dict      			= kwargs.pop("encoder"					)
           lowerCamelCase       :				Tuple      			= encoder_config.pop("model_type"					)
           lowerCamelCase       :				int      			= kwargs.pop("decoder"					)
           lowerCamelCase       :				List[Any]      			= decoder_config.pop("model_type"					)

           lowerCamelCase       :				str      			= AutoConfig.for_model(UpperCamelCase__					,  **UpperCamelCase__					)
           lowerCamelCase       :				str      			= AutoConfig.for_model(UpperCamelCase__					,  **UpperCamelCase__					)
           lowerCamelCase       :				Tuple      			= True







    @classmethod
    def    _lowercase					(   cls					,  UpperCamelCase__					,  UpperCamelCase__					,  **UpperCamelCase__					)					->				PretrainedConfig:
           logger.info("Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"					)
           lowerCamelCase       :				Dict      			= True
           lowerCamelCase       :				Union[str, Any]      			= True

           return cls(encoder=encoder_config.to_dict()					,  decoder=decoder_config.to_dict()					,  **UpperCamelCase__					)







    def    _lowercase					(   self					)					->				Tuple:
           lowerCamelCase       :				Tuple      			= copy.deepcopy(self.__dict__					)
           lowerCamelCase       :				Optional[int]      			= self.encoder.to_dict()
           lowerCamelCase       :				List[str]      			= self.decoder.to_dict()
           lowerCamelCase       :				Dict      			= self.__class__.model_type
           return output






