


'''simple docstring'''
from typing import TYPE_CHECKING

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


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

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

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case							      =     [
		    '''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:
		__snake_case							      =     [
		    '''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

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






'''simple docstring'''




from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType


class  SCREAMING_SNAKE_CASE    (a__							):
     lowerCAmelCase					=       ['''image_processor''', '''tokenizer''']
     lowerCAmelCase					=       '''BlipImageProcessor'''
     lowerCAmelCase					=       ('''BertTokenizer''', '''BertTokenizerFast''')


     def __init__(						self						,	_UpperCAmelCase						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: int      =       False
          super().__init__(_UpperCAmelCase						,	_UpperCAmelCase)
          __A						: Optional[int]      =       self.image_processor


     def __call__(						self						,	_UpperCAmelCase = None						,	_UpperCAmelCase = None						,	_UpperCAmelCase = True						,	_UpperCAmelCase = False						,	_UpperCAmelCase = None						,	_UpperCAmelCase = None						,	_UpperCAmelCase = 0						,	_UpperCAmelCase = None						,	_UpperCAmelCase = None						,	_UpperCAmelCase = False						,	_UpperCAmelCase = False						,	_UpperCAmelCase = False						,	_UpperCAmelCase = False						,	_UpperCAmelCase = False						,	_UpperCAmelCase = True						,	_UpperCAmelCase = None						,	**_UpperCAmelCase						,	):

          '''simple docstring'''






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

          # Get only text
          if images is None:
               __A						: int      =       self.tokenizer
               __A						: Optional[Any]      =       self.tokenizer(
                   text=_UpperCAmelCase						,	add_special_tokens=_UpperCAmelCase						,	padding=_UpperCAmelCase						,	truncation=_UpperCAmelCase						,	max_length=_UpperCAmelCase						,	stride=_UpperCAmelCase						,	pad_to_multiple_of=_UpperCAmelCase						,	return_attention_mask=_UpperCAmelCase						,	return_overflowing_tokens=_UpperCAmelCase						,	return_special_tokens_mask=_UpperCAmelCase						,	return_offsets_mapping=_UpperCAmelCase						,	return_token_type_ids=_UpperCAmelCase						,	return_length=_UpperCAmelCase						,	verbose=_UpperCAmelCase						,	return_tensors=_UpperCAmelCase						,	**_UpperCAmelCase						,	)
               return text_encoding

          # add pixel_values
          __A						: List[Any]      =       self.image_processor(_UpperCAmelCase						,	return_tensors=_UpperCAmelCase)

          if text is not None:
               __A						: Optional[Any]      =       self.tokenizer(
                   text=_UpperCAmelCase						,	add_special_tokens=_UpperCAmelCase						,	padding=_UpperCAmelCase						,	truncation=_UpperCAmelCase						,	max_length=_UpperCAmelCase						,	stride=_UpperCAmelCase						,	pad_to_multiple_of=_UpperCAmelCase						,	return_attention_mask=_UpperCAmelCase						,	return_overflowing_tokens=_UpperCAmelCase						,	return_special_tokens_mask=_UpperCAmelCase						,	return_offsets_mapping=_UpperCAmelCase						,	return_token_type_ids=_UpperCAmelCase						,	return_length=_UpperCAmelCase						,	verbose=_UpperCAmelCase						,	return_tensors=_UpperCAmelCase						,	**_UpperCAmelCase						,	)
          else:
               __A						: int      =       None

          if text_encoding is not None:
               encoding_image_processor.update(_UpperCAmelCase)

          return encoding_image_processor


     def 							SCREAMING_SNAKE_CASE  (						self						,	*_UpperCAmelCase						,	**_UpperCAmelCase):

          '''simple docstring'''






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


     def 							SCREAMING_SNAKE_CASE  (						self						,	*_UpperCAmelCase						,	**_UpperCAmelCase):

          '''simple docstring'''






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


     @property
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: List[str]      =       self.tokenizer.model_input_names
          __A						: Tuple      =       self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))