






"""simple docstring"""







import warnings

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


class      UpperCamelCase		(__snake_case     ):
						_SCREAMING_SNAKE_CASE  : Dict												=		["""image_processor""", """tokenizer"""]
						_SCREAMING_SNAKE_CASE  : Dict												=		"""ChineseCLIPImageProcessor"""
						_SCREAMING_SNAKE_CASE  : List[Any]												=		("""BertTokenizer""", """BertTokenizerFast""")






						def __init__(		self  :Optional[Any]			, __magic_name__  :Dict=None			, __magic_name__  :Optional[Any]=None			, **__magic_name__  :Any				)      ->List[str]:
										lowercase    :      Dict       = None
										if "feature_extractor" in kwargs:
														warnings.warn(
														    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
														    """ instead."""			, __magic_name__			, )
														lowercase    :      Optional[Any]       = kwargs.pop("""feature_extractor"""				)

										lowercase    :      Optional[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__(__magic_name__			, __magic_name__				)
										lowercase    :      List[Any]       = self.image_processor






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

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

										if images is not None:
														lowercase    :      int       = self.image_processor(__magic_name__			, return_tensors=__magic_name__			, **__magic_name__				)

										if text is not None and images is not None:
														lowercase    :      List[str]       = image_features.pixel_values
														return encoding
										elif text is not None:
														return encoding
										else:
														return BatchEncoding(data=dict(**__magic_name__				)			, tensor_type=__magic_name__				)






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






						def      __snake_case      (		self  :str			, *__magic_name__  :Optional[Any]			, **__magic_name__  :Union[str, Any]				)      ->Optional[Any]:
										return self.tokenizer.decode(*__magic_name__			, **__magic_name__				)






						@property
						def      __snake_case      (		self  :int				)      ->List[str]:
										lowercase    :      Any       = self.tokenizer.model_input_names
										lowercase    :      Tuple       = self.image_processor.model_input_names
										return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)






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








"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_lowerCAmelCase            =	{
    'configuration_mobilebert': [
        'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'MobileBertConfig',
        'MobileBertOnnxConfig',
    ],
    'tokenization_mobilebert': ['MobileBertTokenizer'],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCAmelCase            =	['MobileBertTokenizerFast']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCAmelCase            =	[
				    'MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'MobileBertForMaskedLM',
				    'MobileBertForMultipleChoice',
				    'MobileBertForNextSentencePrediction',
				    'MobileBertForPreTraining',
				    'MobileBertForQuestionAnswering',
				    'MobileBertForSequenceClassification',
				    'MobileBertForTokenClassification',
				    'MobileBertLayer',
				    'MobileBertModel',
				    'MobileBertPreTrainedModel',
				    'load_tf_weights_in_mobilebert',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCAmelCase            =	[
				    'TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFMobileBertForMaskedLM',
				    'TFMobileBertForMultipleChoice',
				    'TFMobileBertForNextSentencePrediction',
				    'TFMobileBertForPreTraining',
				    'TFMobileBertForQuestionAnswering',
				    'TFMobileBertForSequenceClassification',
				    'TFMobileBertForTokenClassification',
				    'TFMobileBertMainLayer',
				    'TFMobileBertModel',
				    'TFMobileBertPreTrainedModel',
				]


if TYPE_CHECKING:
				from .configuration_mobilebert import (
				    MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    MobileBertConfig,
				    MobileBertOnnxConfig,
				)
				from .tokenization_mobilebert import MobileBertTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_mobilebert_fast import MobileBertTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_mobilebert import (
								    MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    MobileBertForMaskedLM,
								    MobileBertForMultipleChoice,
								    MobileBertForNextSentencePrediction,
								    MobileBertForPreTraining,
								    MobileBertForQuestionAnswering,
								    MobileBertForSequenceClassification,
								    MobileBertForTokenClassification,
								    MobileBertLayer,
								    MobileBertModel,
								    MobileBertPreTrainedModel,
								    load_tf_weights_in_mobilebert,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_mobilebert import (
								    TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFMobileBertForMaskedLM,
								    TFMobileBertForMultipleChoice,
								    TFMobileBertForNextSentencePrediction,
								    TFMobileBertForPreTraining,
								    TFMobileBertForQuestionAnswering,
								    TFMobileBertForSequenceClassification,
								    TFMobileBertForTokenClassification,
								    TFMobileBertMainLayer,
								    TFMobileBertModel,
								    TFMobileBertPreTrainedModel,
								)

else:
				import sys

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