

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


class      lowerCamelCase_ (			_lowerCAmelCase):
 _lowerCAmelCase									=	['''image_processor''', '''tokenizer''']
 _lowerCAmelCase									=	'''EfficientNetImageProcessor'''
 _lowerCAmelCase									=	('''BertTokenizer''', '''BertTokenizerFast''')




 def __init__(			self  ,  _UpperCAmelCase  ,  _UpperCAmelCase							):
   super().__init__(_UpperCAmelCase  ,  _UpperCAmelCase							)




 def __call__(			self  ,  _UpperCAmelCase=None  ,  _UpperCAmelCase=None  ,  _UpperCAmelCase="max_length"  ,  _UpperCAmelCase=64  ,  _UpperCAmelCase=None  ,  **_UpperCAmelCase							):
   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:
     __UpperCAmelCase	:  Union[str, Any]		=     self.tokenizer(
         _UpperCAmelCase  ,  padding=_UpperCAmelCase  ,  max_length=_UpperCAmelCase  ,  return_tensors=_UpperCAmelCase  ,  **_UpperCAmelCase							)

   if images is not None:
     __UpperCAmelCase	:  Union[str, Any]		=     self.image_processor(_UpperCAmelCase  ,  return_tensors=_UpperCAmelCase  ,  **_UpperCAmelCase							)

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




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   return self.tokenizer.batch_decode(*_UpperCAmelCase  ,  **_UpperCAmelCase							)




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   return self.tokenizer.decode(*_UpperCAmelCase  ,  **_UpperCAmelCase							)




 @property
 def     a       (			self							):
   __UpperCAmelCase	:  Tuple		=     self.tokenizer.model_input_names
   __UpperCAmelCase	:  List[Any]		=     self.image_processor.model_input_names
   return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)









"""simple docstring"""
from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE					:       Tuple							   =							{
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
			if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			SCREAMING_SNAKE_CASE					:       Optional[Any]							   =							["""RealmTokenizerFast"""]

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			SCREAMING_SNAKE_CASE					:       Dict							   =							[
			    """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """RealmEmbedder""",
			    """RealmForOpenQA""",
			    """RealmKnowledgeAugEncoder""",
			    """RealmPreTrainedModel""",
			    """RealmReader""",
			    """RealmScorer""",
			    """load_tf_weights_in_realm""",
			]
			SCREAMING_SNAKE_CASE					:       Union[str, Any]							   =							["""RealmRetriever"""]


if TYPE_CHECKING:
			from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
			from .tokenization_realm import RealmTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_realm import RealmTokenizerFast

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_realm import (
						    REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
						    RealmEmbedder,
						    RealmForOpenQA,
						    RealmKnowledgeAugEncoder,
						    RealmPreTrainedModel,
						    RealmReader,
						    RealmScorer,
						    load_tf_weights_in_realm,
						)
						from .retrieval_realm import RealmRetriever


else:
			import sys

			SCREAMING_SNAKE_CASE					:       str							   =							_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





