
import warnings

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



class 		UpperCamelCase__  (	__lowercase   ):
   _SCREAMING_SNAKE_CASE				:							int     	=				["image_processor", "tokenizer"]
   _SCREAMING_SNAKE_CASE				:							Union[str, Any]     	=				"CLIPImageProcessor"
   _SCREAMING_SNAKE_CASE				:							Optional[int]     	=				("CLIPTokenizer", "CLIPTokenizerFast")
   def __init__(self			: int ,    snake_case_			: Tuple=None ,    snake_case_			: int=None ,    **snake_case_			: List[str]       ):
    __a			:  Optional[Any]		    =  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_ ,    )
     __a			:  int		    =  kwargs.pop('''feature_extractor'''       )

    __a			:  List[Any]		    =  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			: Optional[int] ,    snake_case_			: int=None ,    snake_case_			: int=None ,    snake_case_			: Union[str, Any]=None ,    **snake_case_			: int       ):

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

    if text is not None:
     __a			:  List[str]		    =  self.tokenizer(snake_case_ ,    return_tensors=snake_case_ ,    **snake_case_       )

    if images is not None:
     __a			:  Optional[int]		    =  self.image_processor(snake_case_ ,    return_tensors=snake_case_ ,    **snake_case_       )

    if text is not None and images is not None:
     __a			:  Union[str, Any]		    =  image_features.pixel_values
     return encoding
    elif text is not None:
     return encoding
    else:
     return BatchEncoding(data=dict(**snake_case_       ) ,    tensor_type=snake_case_       )
   def 				lowerCAmelCase      (self			: Tuple ,    *snake_case_			: str ,    **snake_case_			: Optional[int]       ):
    return self.tokenizer.batch_decode(*snake_case_ ,    **snake_case_       )
   def 				lowerCAmelCase      (self			: List[str] ,    *snake_case_			: List[str] ,    **snake_case_			: str       ):
    return self.tokenizer.decode(*snake_case_ ,    **snake_case_       )
   @property
   def 				lowerCAmelCase      (self			: List[Any]       ):
    __a			:  Dict		    =  self.tokenizer.model_input_names
    __a			:  Dict		    =  self.image_processor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )
   @property
   def 				lowerCAmelCase      (self			: Any       ):
    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 				lowerCAmelCase      (self			: Optional[Any]       ):
    warnings.warn(
        '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.''' ,    snake_case_ ,    )
    return self.image_processor


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


lowercase__          ={
    'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'],
    'configuration_data2vec_text': [
        'DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecTextConfig',
        'Data2VecTextOnnxConfig',
    ],
    'configuration_data2vec_vision': [
        'DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecVisionConfig',
        'Data2VecVisionOnnxConfig',
    ],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase__          =[
          'DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecAudioForAudioFrameClassification',
          'Data2VecAudioForCTC',
          'Data2VecAudioForSequenceClassification',
          'Data2VecAudioForXVector',
          'Data2VecAudioModel',
          'Data2VecAudioPreTrainedModel',
      ]
      lowercase__          =[
          'DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecTextForCausalLM',
          'Data2VecTextForMaskedLM',
          'Data2VecTextForMultipleChoice',
          'Data2VecTextForQuestionAnswering',
          'Data2VecTextForSequenceClassification',
          'Data2VecTextForTokenClassification',
          'Data2VecTextModel',
          'Data2VecTextPreTrainedModel',
      ]
      lowercase__          =[
          'DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecVisionForImageClassification',
          'Data2VecVisionForMaskedImageModeling',
          'Data2VecVisionForSemanticSegmentation',
          'Data2VecVisionModel',
          'Data2VecVisionPreTrainedModel',
      ]

if is_tf_available():
      lowercase__          =[
          'TFData2VecVisionForImageClassification',
          'TFData2VecVisionForSemanticSegmentation',
          'TFData2VecVisionModel',
          'TFData2VecVisionPreTrainedModel',
      ]

if TYPE_CHECKING:
      from .configuration_dataavec_audio import DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP, DataaVecAudioConfig
      from .configuration_dataavec_text import (
          DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
          DataaVecTextConfig,
          DataaVecTextOnnxConfig,
      )
      from .configuration_dataavec_vision import (
          DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP,
          DataaVecVisionConfig,
          DataaVecVisionOnnxConfig,
      )

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_dataavec_audio import (
                DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecAudioForAudioFrameClassification,
                DataaVecAudioForCTC,
                DataaVecAudioForSequenceClassification,
                DataaVecAudioForXVector,
                DataaVecAudioModel,
                DataaVecAudioPreTrainedModel,
            )
            from .modeling_dataavec_text import (
                DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecTextForCausalLM,
                DataaVecTextForMaskedLM,
                DataaVecTextForMultipleChoice,
                DataaVecTextForQuestionAnswering,
                DataaVecTextForSequenceClassification,
                DataaVecTextForTokenClassification,
                DataaVecTextModel,
                DataaVecTextPreTrainedModel,
            )
            from .modeling_dataavec_vision import (
                DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecVisionForImageClassification,
                DataaVecVisionForMaskedImageModeling,
                DataaVecVisionForSemanticSegmentation,
                DataaVecVisionModel,
                DataaVecVisionPreTrainedModel,
            )
      if is_tf_available():
            from .modeling_tf_dataavec_vision import (
                TFDataaVecVisionForImageClassification,
                TFDataaVecVisionForSemanticSegmentation,
                TFDataaVecVisionModel,
                TFDataaVecVisionPreTrainedModel,
            )

else:
      import sys

      lowercase__          =_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
