"""simple docstring"""


from typing import Optional, Union

from ...file_utils import TensorType
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, TruncationStrategy






class  a__     ( lowerCamelCase_						):
   snake_case_				=   "MarkupLMFeatureExtractor"
   snake_case_				=   ("MarkupLMTokenizer", "MarkupLMTokenizerFast")
   snake_case_				=   True


   def __call__(  self,					_UpperCAmelCase=None,					_UpperCAmelCase=None,					_UpperCAmelCase=None,					_UpperCAmelCase=None,					_UpperCAmelCase=None,					_UpperCAmelCase = True,					_UpperCAmelCase = False,					_UpperCAmelCase = None,					_UpperCAmelCase = None,					_UpperCAmelCase = 0,					_UpperCAmelCase = None,					_UpperCAmelCase = None,					_UpperCAmelCase = None,					_UpperCAmelCase = False,					_UpperCAmelCase = False,					_UpperCAmelCase = False,					_UpperCAmelCase = False,					_UpperCAmelCase = True,					_UpperCAmelCase = None,					**_UpperCAmelCase,					):
        '''simple docstring'''



        if self.parse_html:
             if html_strings is None:
                  raise ValueError("Make sure to pass HTML strings in case `parse_html` is set to `True`"	)

             if nodes is not None or xpaths is not None or node_labels is not None:
                  raise ValueError(
                      "Please don\'t pass nodes, xpaths nor node labels in case `parse_html` is set to `True`"	)

             lowercase__								=				self.feature_extractor(__SCREAMING_SNAKE_CASE	)
             lowercase__								=				features['''nodes''']
             lowercase__								=				features['''xpaths''']
        else:
             if html_strings is not None:
                  raise ValueError("You have passed HTML strings but `parse_html` is set to `False`."	)
             if nodes is None or xpaths is None:
                  raise ValueError("Make sure to pass nodes and xpaths in case `parse_html` is set to `False`"	)

        # # second, apply the tokenizer
        if questions is not None and self.parse_html:
             if isinstance(__SCREAMING_SNAKE_CASE,					__SCREAMING_SNAKE_CASE	):
                  lowercase__								=				[questions]  # add batch dimension (as the feature extractor always adds a batch dimension)

        lowercase__								=				self.tokenizer(
            text=questions if questions is not None else nodes,					text_pair=nodes if questions is not None else None,					xpaths=__SCREAMING_SNAKE_CASE,					node_labels=__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,					)

        return encoded_inputs


   def 						snake_case__						(  self,					*_UpperCAmelCase,					**_UpperCAmelCase	):
        '''simple docstring'''



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


   def 						snake_case__						(  self,					*_UpperCAmelCase,					**_UpperCAmelCase	):
        '''simple docstring'''



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


   @property
   def 						snake_case__						(  self	):
        '''simple docstring'''



        lowercase__								=				self.tokenizer.model_input_names
        return tokenizer_input_names






'''simple docstring'''







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							,				__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





											super().__init__(__SCREAMING_SNAKE_CASE							,				__SCREAMING_SNAKE_CASE						)






					def __call__(  self							,				__SCREAMING_SNAKE_CASE=None							,				__SCREAMING_SNAKE_CASE=None							,				__SCREAMING_SNAKE_CASE="max_length"							,				__SCREAMING_SNAKE_CASE=64							,				__SCREAMING_SNAKE_CASE=None							,				**__SCREAMING_SNAKE_CASE						):


											"""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:
																	lowercase_      :	str						=			self.tokenizer(
																	    __SCREAMING_SNAKE_CASE							,				padding=__SCREAMING_SNAKE_CASE							,				max_length=__SCREAMING_SNAKE_CASE							,				return_tensors=__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)

											if images is not None:
																	lowercase_      :	int						=			self.image_processor(__SCREAMING_SNAKE_CASE							,				return_tensors=__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						)

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






					def       _snake_case       (  self							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





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






					def       _snake_case       (  self							,				*__SCREAMING_SNAKE_CASE							,				**__SCREAMING_SNAKE_CASE						):


											"""simple docstring"""





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






					@property
					def       _snake_case       (  self						):


											"""simple docstring"""





											lowercase_      :	Dict						=			self.tokenizer.model_input_names
											lowercase_      :	Optional[int]						=			self.image_processor.model_input_names
											return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)



