
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__							(     lowerCAmelCase_	):
				lowercase			    =  ['image_processor', 'tokenizer']
				lowercase			    =  'FlavaImageProcessor'
				lowercase			    =  ('BertTokenizer', 'BertTokenizerFast')






				def __init__(						self					:      Optional[Any]    ,     a					:      List[Any]=None    ,     a					:      int=None    ,     **a					:      Any   ):






							'''simple docstring'''







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

							lowerCAmelCase__      :      Union[str, Any]         =		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__(__a    ,     __a   )
							lowerCAmelCase__      :      Optional[int]         =		self.image_processor






				def __call__(						self					:      Tuple    ,     a					:      int = None    ,     a					:      Union[str, Any] = None    ,     a					:      Optional[Any] = True    ,     a					:      Tuple = False    ,     a					:      Optional[int] = False    ,     a					:      List[str] = None    ,     a					:      Tuple = 0    ,     a					:      Optional[int] = None    ,     a					:      Optional[int] = None    ,     a					:      Optional[int] = None    ,     a					:      List[Any] = None    ,     a					:      Dict = None    ,     a					:      int = False    ,     a					:      str = False    ,     a					:      Any = False    ,     a					:      Dict = False    ,     a					:      int = True    ,     a					:      str = None    ,     **a					:      List[Any]    ,     ):






							'''simple docstring'''







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

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






				def 							_lowerCamelCase		(						self					:      Optional[Any]    ,     *a					:      int    ,     **a					:      str   ):






							'''simple docstring'''







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






				def 							_lowerCamelCase		(						self					:      Dict    ,     *a					:      Any    ,     **a					:      Optional[int]   ):






							'''simple docstring'''







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






				@property
				def 							_lowerCamelCase		(						self					:      Dict   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		self.tokenizer.model_input_names
							lowerCAmelCase__      :      Union[str, Any]         =		self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )






				@property
				def 							_lowerCamelCase		(						self					:      Dict   ):






							'''simple docstring'''







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






				@property
				def 							_lowerCamelCase		(						self					:      Optional[int]   ):






							'''simple docstring'''







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



'''simple docstring'''



from typing import TYPE_CHECKING

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


__lowercase	:						str       =	{
    'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'],
    'configuration_data2vec_text': [
        'DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecTextConfig',
        'Data2VecTextOnnxConfig',
    ],
    'configuration_data2vec_vision': [
        'DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecVisionConfig',
        'Data2VecVisionOnnxConfig',
    ],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase	:						str       =	[
	    'DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'Data2VecAudioForAudioFrameClassification',
	    'Data2VecAudioForCTC',
	    'Data2VecAudioForSequenceClassification',
	    'Data2VecAudioForXVector',
	    'Data2VecAudioModel',
	    'Data2VecAudioPreTrainedModel',
	]
	__lowercase	:						Tuple       =	[
	    'DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'Data2VecTextForCausalLM',
	    'Data2VecTextForMaskedLM',
	    'Data2VecTextForMultipleChoice',
	    'Data2VecTextForQuestionAnswering',
	    'Data2VecTextForSequenceClassification',
	    'Data2VecTextForTokenClassification',
	    'Data2VecTextModel',
	    'Data2VecTextPreTrainedModel',
	]
	__lowercase	:						Dict       =	[
	    'DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'Data2VecVisionForImageClassification',
	    'Data2VecVisionForMaskedImageModeling',
	    'Data2VecVisionForSemanticSegmentation',
	    'Data2VecVisionModel',
	    'Data2VecVisionPreTrainedModel',
	]

if is_tf_available():
	__lowercase	:						Optional[Any]       =	[
	    'TFData2VecVisionForImageClassification',
	    'TFData2VecVisionForSemanticSegmentation',
	    'TFData2VecVisionModel',
	    'TFData2VecVisionPreTrainedModel',
	]

if TYPE_CHECKING:
	from .configuration_dataavec_audio import DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP, DataaVecAudioConfig
	from .configuration_dataavec_text import (
	    DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    DataaVecTextConfig,
	    DataaVecTextOnnxConfig,
	)
	from .configuration_dataavec_vision import (
	    DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    DataaVecVisionConfig,
	    DataaVecVisionOnnxConfig,
	)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_dataavec_audio import (
		    DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DataaVecAudioForAudioFrameClassification,
		    DataaVecAudioForCTC,
		    DataaVecAudioForSequenceClassification,
		    DataaVecAudioForXVector,
		    DataaVecAudioModel,
		    DataaVecAudioPreTrainedModel,
		)
		from .modeling_dataavec_text import (
		    DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DataaVecTextForCausalLM,
		    DataaVecTextForMaskedLM,
		    DataaVecTextForMultipleChoice,
		    DataaVecTextForQuestionAnswering,
		    DataaVecTextForSequenceClassification,
		    DataaVecTextForTokenClassification,
		    DataaVecTextModel,
		    DataaVecTextPreTrainedModel,
		)
		from .modeling_dataavec_vision import (
		    DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DataaVecVisionForImageClassification,
		    DataaVecVisionForMaskedImageModeling,
		    DataaVecVisionForSemanticSegmentation,
		    DataaVecVisionModel,
		    DataaVecVisionPreTrainedModel,
		)
	if is_tf_available():
		from .modeling_tf_dataavec_vision import (
		    TFDataaVecVisionForImageClassification,
		    TFDataaVecVisionForSemanticSegmentation,
		    TFDataaVecVisionModel,
		    TFDataaVecVisionPreTrainedModel,
		)

else:
	import sys

	__lowercase	:						int       =	_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



