


"""simple docstring"""






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__		):

		"""simple docstring"""





		A    =							["image_processor", "tokenizer"]
		A    =							"FlavaImageProcessor"
		A    =							("BertTokenizer", "BertTokenizerFast")
		def __init__( self					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=None					,				**SCREAMING_SNAKE_CASE__   )      ->	List[Any]:

					"""simple docstring"""



					_UpperCamelCase					:Optional[Any]					     =	None
					if "feature_extractor" in kwargs:
								warnings.warn(
								    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
								    ''' instead.'''					,				SCREAMING_SNAKE_CASE__					,				)
								_UpperCamelCase					:Dict					     =	kwargs.pop('''feature_extractor'''   )

					_UpperCamelCase					:List[str]					     =	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__(SCREAMING_SNAKE_CASE__					,				SCREAMING_SNAKE_CASE__   )
					_UpperCamelCase					:List[str]					     =	self.image_processor
		def __call__( self					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = True					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = 0					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = None					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = False					,				SCREAMING_SNAKE_CASE__ = True					,				SCREAMING_SNAKE_CASE__ = None					,				**SCREAMING_SNAKE_CASE__					,				)      ->	Optional[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:
								_UpperCamelCase					:List[str]					     =	self.tokenizer(
								    text=SCREAMING_SNAKE_CASE__					,				add_special_tokens=SCREAMING_SNAKE_CASE__					,				padding=SCREAMING_SNAKE_CASE__					,				truncation=SCREAMING_SNAKE_CASE__					,				max_length=SCREAMING_SNAKE_CASE__					,				stride=SCREAMING_SNAKE_CASE__					,				pad_to_multiple_of=SCREAMING_SNAKE_CASE__					,				return_token_type_ids=SCREAMING_SNAKE_CASE__					,				return_attention_mask=SCREAMING_SNAKE_CASE__					,				return_overflowing_tokens=SCREAMING_SNAKE_CASE__					,				return_special_tokens_mask=SCREAMING_SNAKE_CASE__					,				return_offsets_mapping=SCREAMING_SNAKE_CASE__					,				return_length=SCREAMING_SNAKE_CASE__					,				verbose=SCREAMING_SNAKE_CASE__					,				return_tensors=SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__					,				)
					if images is not None:
								_UpperCamelCase					:List[str]					     =	self.image_processor(
								    SCREAMING_SNAKE_CASE__					,				return_image_mask=SCREAMING_SNAKE_CASE__					,				return_codebook_pixels=SCREAMING_SNAKE_CASE__					,				return_tensors=SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__					,				)

					if text is not None and images is not None:
								encoding.update(SCREAMING_SNAKE_CASE__   )
								return encoding
					elif text is not None:
								return encoding
					else:
								return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE__   )					,				tensor_type=SCREAMING_SNAKE_CASE__   )
		def   _UpperCamelCase( self					,				*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )      ->	Optional[int]:

					"""simple docstring"""



					return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )
		def   _UpperCamelCase( self					,				*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )      ->	Any:

					"""simple docstring"""



					return self.tokenizer.decode(*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )
		@property
		def   _UpperCamelCase( self   )      ->	str:

					"""simple docstring"""



					_UpperCamelCase					:Any					     =	self.tokenizer.model_input_names
					_UpperCamelCase					:int					     =	self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )
		@property
		def   _UpperCamelCase( self   )      ->	List[Any]:

					"""simple docstring"""



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





		@property
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



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





"""simple docstring"""






import os
import sys

UpperCamelCase__				:Union[str, Any]			   =	os.path.join(os.path.dirname(__file__), """src""")
sys.path.append(SRC_DIR)


from transformers import (
    AutoConfig,
    AutoModel,
    AutoModelForCausalLM,
    AutoModelForMaskedLM,
    AutoModelForQuestionAnswering,
    AutoModelForSequenceClassification,
    AutoTokenizer,
    add_start_docstrings,
)


UpperCamelCase__				:List[Any]			   =	[
    """torch""",
    """numpy""",
    """tokenizers""",
    """filelock""",
    """requests""",
    """tqdm""",
    """regex""",
    """sentencepiece""",
    """sacremoses""",
    """importlib_metadata""",
    """huggingface_hub""",
]





@add_start_docstrings(AutoConfig.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  int:
			return AutoConfig.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoTokenizer.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  int:
			return AutoTokenizer.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoModel.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  Dict:
			return AutoModel.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoModelForCausalLM.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  Dict:
			return AutoModelForCausalLM.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoModelForMaskedLM.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  Dict:
			return AutoModelForMaskedLM.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoModelForSequenceClassification.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  Dict:
			return AutoModelForSequenceClassification.from_pretrained(*snake_case__       ,					**snake_case__		)





@add_start_docstrings(AutoModelForQuestionAnswering.__doc__		)
def 				A_       ( *snake_case__       ,					**snake_case__		)					->  Union[str, Any]:
			return AutoModelForQuestionAnswering.from_pretrained(*snake_case__       ,					**snake_case__		)

