import warnings
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 						a__							(       __snake_case		):
			A__    :       Any        =      ['image_processor', 'tokenizer']
			A__    :       List[Any]        =      'FlavaImageProcessor'
			A__    :       Tuple        =      ('BertTokenizer', 'BertTokenizerFast')



			def __init__(						self				,						UpperCAmelCase=None				,						UpperCAmelCase=None				,						**UpperCAmelCase   )			->   Any:
								__a		 =       None
								if "feature_extractor" in kwargs:
													warnings.warn(
													    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
													    ' instead.'				,						_lowerCAmelCase				,						)
													__a		 =       kwargs.pop('feature_extractor'   )

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



			def __call__(						self				,						UpperCAmelCase = None				,						UpperCAmelCase = None				,						UpperCAmelCase = True				,						UpperCAmelCase = False				,						UpperCAmelCase = False				,						UpperCAmelCase = None				,						UpperCAmelCase = 0				,						UpperCAmelCase = None				,						UpperCAmelCase = None				,						UpperCAmelCase = None				,						UpperCAmelCase = None				,						UpperCAmelCase = None				,						UpperCAmelCase = False				,						UpperCAmelCase = False				,						UpperCAmelCase = False				,						UpperCAmelCase = False				,						UpperCAmelCase = True				,						UpperCAmelCase = None				,						**UpperCAmelCase				,						)			->   List[str]:

								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:
													__a		 =       self.tokenizer(
													    text=_lowerCAmelCase				,						add_special_tokens=_lowerCAmelCase				,						padding=_lowerCAmelCase				,						truncation=_lowerCAmelCase				,						max_length=_lowerCAmelCase				,						stride=_lowerCAmelCase				,						pad_to_multiple_of=_lowerCAmelCase				,						return_token_type_ids=_lowerCAmelCase				,						return_attention_mask=_lowerCAmelCase				,						return_overflowing_tokens=_lowerCAmelCase				,						return_special_tokens_mask=_lowerCAmelCase				,						return_offsets_mapping=_lowerCAmelCase				,						return_length=_lowerCAmelCase				,						verbose=_lowerCAmelCase				,						return_tensors=_lowerCAmelCase				,						**_lowerCAmelCase				,						)
								if images is not None:
													__a		 =       self.image_processor(
													    _lowerCAmelCase				,						return_image_mask=_lowerCAmelCase				,						return_codebook_pixels=_lowerCAmelCase				,						return_tensors=_lowerCAmelCase				,						**_lowerCAmelCase				,						)

								if text is not None and images is not None:
													encoding.update(_lowerCAmelCase   )
													return encoding
								elif text is not None:
													return encoding
								else:
													return BatchEncoding(data=dict(**_lowerCAmelCase   )				,						tensor_type=_lowerCAmelCase   )



			def __SCREAMING_SNAKE_CASE							(						self				,						*UpperCAmelCase				,						**UpperCAmelCase   )			->   Union[str, Any]:
								return self.tokenizer.batch_decode(*_lowerCAmelCase				,						**_lowerCAmelCase   )



			def __SCREAMING_SNAKE_CASE							(						self				,						*UpperCAmelCase				,						**UpperCAmelCase   )			->   Union[str, Any]:
								return self.tokenizer.decode(*_lowerCAmelCase				,						**_lowerCAmelCase   )



			@property
			def __SCREAMING_SNAKE_CASE							(						self   )			->   int:
								__a		 =       self.tokenizer.model_input_names
								__a		 =       self.image_processor.model_input_names
								return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )



			@property
			def __SCREAMING_SNAKE_CASE							(						self   )			->   List[str]:
								warnings.warn(
								    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'				,						_lowerCAmelCase				,						)
								return self.image_processor_class







			@property
			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[int]:
								warnings.warn(
								    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'				,						_lowerCAmelCase				,						)
								return self.image_processor





from typing import TYPE_CHECKING

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


lowerCamelCase_    :		Optional[int]							=	{"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLNetConfig"""]}

try:
	if not is_sentencepiece_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	lowerCamelCase_    :		str							=	["""XLNetTokenizer"""]

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

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	lowerCamelCase_    :		Union[str, Any]							=	[
	    """XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XLNetForMultipleChoice""",
	    """XLNetForQuestionAnswering""",
	    """XLNetForQuestionAnsweringSimple""",
	    """XLNetForSequenceClassification""",
	    """XLNetForTokenClassification""",
	    """XLNetLMHeadModel""",
	    """XLNetModel""",
	    """XLNetPreTrainedModel""",
	    """load_tf_weights_in_xlnet""",
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	lowerCamelCase_    :		Optional[int]							=	[
	    """TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TFXLNetForMultipleChoice""",
	    """TFXLNetForQuestionAnsweringSimple""",
	    """TFXLNetForSequenceClassification""",
	    """TFXLNetForTokenClassification""",
	    """TFXLNetLMHeadModel""",
	    """TFXLNetMainLayer""",
	    """TFXLNetModel""",
	    """TFXLNetPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

	try:
		if not is_sentencepiece_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_xlnet import XLNetTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_xlnet_fast import XLNetTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_xlnet import (
		    XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XLNetForMultipleChoice,
		    XLNetForQuestionAnswering,
		    XLNetForQuestionAnsweringSimple,
		    XLNetForSequenceClassification,
		    XLNetForTokenClassification,
		    XLNetLMHeadModel,
		    XLNetModel,
		    XLNetPreTrainedModel,
		    load_tf_weights_in_xlnet,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_xlnet import (
		    TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFXLNetForMultipleChoice,
		    TFXLNetForQuestionAnsweringSimple,
		    TFXLNetForSequenceClassification,
		    TFXLNetForTokenClassification,
		    TFXLNetLMHeadModel,
		    TFXLNetMainLayer,
		    TFXLNetModel,
		    TFXLNetPreTrainedModel,
		)

else:
	import sys

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




