






from typing import TYPE_CHECKING

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


lowerCamelCase_		  =						{
    'configuration_realm': ['REALM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RealmConfig'],
    'tokenization_realm': ['RealmTokenizer'],
}

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

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowerCamelCase_		  =						[
		    'REALM_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'RealmEmbedder',
		    'RealmForOpenQA',
		    'RealmKnowledgeAugEncoder',
		    'RealmPreTrainedModel',
		    'RealmReader',
		    'RealmScorer',
		    'load_tf_weights_in_realm',
		]
		lowerCamelCase_		  =						['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

		lowerCamelCase_		  =						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)














import warnings

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




class 							a_				(		a_	):


							'''simple docstring'''






							__a:			int									=					['''image_processor''', '''tokenizer''']
							__a:			int									=					'''VideoMAEImageProcessor'''
							__a:			Dict									=					('''CLIPTokenizer''', '''CLIPTokenizerFast''')

							def __init__(	self    ,    lowercase_=None    ,    lowercase_=None    ,    **lowercase_     )      ->      Optional[Any]:
														'''simple docstring'''

														lowerCAmelCase_       		=  None
														if "feature_extractor" in kwargs:
																					warnings.warn(
																					    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
																					    ' instead.'    ,    lowercase_    ,    )
																					lowerCAmelCase_       		=  kwargs.pop('feature_extractor'     )

														lowerCAmelCase_       		=  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__(lowercase_    ,    lowercase_     )
														lowerCAmelCase_       		=  self.image_processor

							def __call__(	self    ,    lowercase_=None    ,    lowercase_=None    ,    lowercase_=None    ,    **lowercase_     )      ->      Optional[int]:
														'''simple docstring'''

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

														if text is not None:
																					lowerCAmelCase_       		=  self.tokenizer(lowercase_    ,    return_tensors=lowercase_    ,    **lowercase_     )

														if videos is not None:
																					lowerCAmelCase_       		=  self.image_processor(lowercase_    ,    return_tensors=lowercase_    ,    **lowercase_     )

														if text is not None and videos is not None:
																					lowerCAmelCase_       		=  image_features.pixel_values
																					return encoding
														elif text is not None:
																					return encoding
														else:
																					return BatchEncoding(data=dict(**lowercase_     )    ,    tensor_type=lowercase_     )

							def   _lowercase (	self    ,    *lowercase_    ,    **lowercase_     )      ->      Union[str, Any]:
														'''simple docstring'''

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

							def   _lowercase (	self    ,    *lowercase_    ,    **lowercase_     )      ->      str:
														'''simple docstring'''

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

							@property
							def   _lowercase (	self     )      ->      Any:
														'''simple docstring'''

														return ["input_ids", "attention_mask", "position_ids", "pixel_values"]

							@property
							def   _lowercase (	self     )      ->      List[str]:
														'''simple docstring'''

														warnings.warn(
														    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'    ,    lowercase_    ,    )
														return self.image_processor_class






							@property
							def   _lowercase (	self     )      ->      int:
														'''simple docstring'''

														warnings.warn(
														    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'    ,    lowercase_    ,    )
														return self.image_processor



