





from typing import TYPE_CHECKING

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


_UpperCAmelCase             =							{
    '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:
     _UpperCAmelCase             =							[
         'DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST',
         'Data2VecAudioForAudioFrameClassification',
         'Data2VecAudioForCTC',
         'Data2VecAudioForSequenceClassification',
         'Data2VecAudioForXVector',
         'Data2VecAudioModel',
         'Data2VecAudioPreTrainedModel',
     ]
     _UpperCAmelCase             =							[
         'DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
         'Data2VecTextForCausalLM',
         'Data2VecTextForMaskedLM',
         'Data2VecTextForMultipleChoice',
         'Data2VecTextForQuestionAnswering',
         'Data2VecTextForSequenceClassification',
         'Data2VecTextForTokenClassification',
         'Data2VecTextModel',
         'Data2VecTextPreTrainedModel',
     ]
     _UpperCAmelCase             =							[
         'DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST',
         'Data2VecVisionForImageClassification',
         'Data2VecVisionForMaskedImageModeling',
         'Data2VecVisionForSemanticSegmentation',
         'Data2VecVisionModel',
         'Data2VecVisionPreTrainedModel',
     ]

if is_tf_available():
     _UpperCAmelCase             =							[
         '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

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






import warnings

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






class        snake_case_    (		__lowercase						):
  A_      							=   ['image_processor', 'tokenizer']
  A_      							=   'ChineseCLIPImageProcessor'
  A_      							=   ('BertTokenizer', 'BertTokenizerFast')






  def __init__(							self			:					Optional[Any]       ,  _snake_case			:					List[Any]=None       ,  _snake_case			:					str=None       ,  **_snake_case			:					int      )->List[str]:






   '''simple docstring'''

   __lowerCAmelCase					:	str      =       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       ,  )
    __lowerCAmelCase					:	List[str]      =       kwargs.pop("""feature_extractor"""      )

   __lowerCAmelCase					:	Union[str, 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      )
   __lowerCAmelCase					:	Any      =       self.image_processor






  def __call__(							self			:					Optional[Any]       ,  _snake_case			:					Tuple=None       ,  _snake_case			:					Tuple=None       ,  _snake_case			:					List[str]=None       ,  **_snake_case			:					Any      )->Union[str, Any]:






   '''simple docstring'''

   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:
    __lowerCAmelCase					:	List[Any]      =       self.tokenizer(_snake_case       ,  return_tensors=_snake_case       ,  **_snake_case      )

   if images is not None:
    __lowerCAmelCase					:	Tuple      =       self.image_processor(_snake_case       ,  return_tensors=_snake_case       ,  **_snake_case      )

   if text is not None and images is not None:
    __lowerCAmelCase					:	Optional[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 				UpperCAmelCase__						(							self			:					Optional[int]       ,  *_snake_case			:					Union[str, Any]       ,  **_snake_case			:					int      )->Optional[Any]:






   '''simple docstring'''

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






  def 				UpperCAmelCase__						(							self			:					Dict       ,  *_snake_case			:					Dict       ,  **_snake_case			:					Any      )->Dict:






   '''simple docstring'''

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






  @property
  def 				UpperCAmelCase__						(							self			:					Optional[int]      )->str:






   '''simple docstring'''

   __lowerCAmelCase					:	Tuple      =       self.tokenizer.model_input_names
   __lowerCAmelCase					:	Tuple      =       self.image_processor.model_input_names
   return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names      )      )






  @property
  def 				UpperCAmelCase__						(							self			:					Dict      )->Union[str, Any]:






   '''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