
"""simple docstring"""


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

class 					A_			(  A__     ):



							"""simple docstring"""






							SCREAMING_SNAKE_CASE_			   =     ["""image_processor""", """tokenizer"""]
							SCREAMING_SNAKE_CASE_			   =     """EfficientNetImageProcessor"""
							SCREAMING_SNAKE_CASE_			   =     ("""BertTokenizer""", """BertTokenizerFast""")





							def __init__(						self						:Dict  ,							lowerCamelCase_						:Tuple  ,							lowerCamelCase_						:Union[str, Any] ):





										"""simple docstring"""

										super().__init__(lowerCamelCase_  ,							lowerCamelCase_ )





							def __call__(						self						:Dict  ,							lowerCamelCase_						:str=None  ,							lowerCamelCase_						:List[Any]=None  ,							lowerCamelCase_						:Dict="max_length"  ,							lowerCamelCase_						:int=64  ,							lowerCamelCase_						:int=None  ,							**lowerCamelCase_						: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__			:  Tuple  =self.tokenizer(
													    lowerCamelCase_  ,							padding=lowerCamelCase_  ,							max_length=lowerCamelCase_  ,							return_tensors=lowerCamelCase_  ,							**lowerCamelCase_ )

										if images is not None:
													lowerCamelCase__			:  Dict  =self.image_processor(lowerCamelCase_  ,							return_tensors=lowerCamelCase_  ,							**lowerCamelCase_ )

										if text is not None and images is not None:
													lowerCamelCase__			:  Optional[Any]  =image_features.pixel_values
													return encoding
										elif text is not None:
													return encoding
										else:
													return BatchEncoding(data=dict(**lowerCamelCase_ )  ,							tensor_type=lowerCamelCase_ )





							def    UpperCAmelCase__							(						self						:Optional[Any]  ,							*lowerCamelCase_						:List[Any]  ,							**lowerCamelCase_						:List[Any] ):





										"""simple docstring"""

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





							def    UpperCAmelCase__							(						self						:Any  ,							*lowerCamelCase_						:List[str]  ,							**lowerCamelCase_						:Dict ):





										"""simple docstring"""

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





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





										"""simple docstring"""

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

"""simple docstring"""


from typing import TYPE_CHECKING

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


lowerCAmelCase			=		{
    """configuration_donut_swin""": ["""DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DonutSwinConfig"""],
    """processing_donut""": ["""DonutProcessor"""],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase			=		[
							    """DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST""",
							    """DonutSwinModel""",
							    """DonutSwinPreTrainedModel""",
							]

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase			=		["""DonutFeatureExtractor"""]
							lowerCAmelCase			=		["""DonutImageProcessor"""]


if TYPE_CHECKING:
							from .configuration_donut_swin import DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, DonutSwinConfig
							from .processing_donut import DonutProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_donut_swin import (
														    DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
														    DonutSwinModel,
														    DonutSwinPreTrainedModel,
														)

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_donut import DonutFeatureExtractor
														from .image_processing_donut import DonutImageProcessor

else:
							import sys

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