





'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__UpperCAmelCase            =       logging.get_logger(__name__)

__UpperCAmelCase            =       {
    """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
    """bert-large-uncased""": """https://huggingface.co/bert-large-uncased/resolve/main/config.json""",
    """bert-base-cased""": """https://huggingface.co/bert-base-cased/resolve/main/config.json""",
    """bert-large-cased""": """https://huggingface.co/bert-large-cased/resolve/main/config.json""",
    """bert-base-multilingual-uncased""": """https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json""",
    """bert-base-multilingual-cased""": """https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json""",
    """bert-base-chinese""": """https://huggingface.co/bert-base-chinese/resolve/main/config.json""",
    """bert-base-german-cased""": """https://huggingface.co/bert-base-german-cased/resolve/main/config.json""",
    """bert-large-uncased-whole-word-masking""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json"""
    ),
    """bert-large-uncased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-large-cased-whole-word-masking-finetuned-squad""": (
        """https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json"""
    ),
    """bert-base-cased-finetuned-mrpc""": """https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json""",
    """bert-base-german-dbmdz-cased""": """https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json""",
    """bert-base-german-dbmdz-uncased""": """https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese""": """https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json""",
    """cl-tohoku/bert-base-japanese-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json"""
    ),
    """cl-tohoku/bert-base-japanese-char-whole-word-masking""": (
        """https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-cased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json"""
    ),
    """TurkuNLP/bert-base-finnish-uncased-v1""": (
        """https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json"""
    ),
    """wietsedv/bert-base-dutch-cased""": """https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json""",
    # See all BERT models at https://huggingface.co/models?filter=bert
}




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	'''bert'''


					def __init__(						self				:			Optional[int]      ,						lowerCamelCase_				:			Union[str, Any]=3_05_22      ,						lowerCamelCase_				:			List[Any]=7_68      ,						lowerCamelCase_				:			Union[str, Any]=12      ,						lowerCamelCase_				:			Any=12      ,						lowerCamelCase_				:			List[str]=30_72      ,						lowerCamelCase_				:			List[str]="gelu"      ,						lowerCamelCase_				:			List[str]=0.1      ,						lowerCamelCase_				:			Optional[int]=0.1      ,						lowerCamelCase_				:			int=5_12      ,						lowerCamelCase_				:			List[Any]=2      ,						lowerCamelCase_				:			List[str]=0.02      ,						lowerCamelCase_				:			int=1e-12      ,						lowerCamelCase_				:			Optional[int]=0      ,						lowerCamelCase_				:			str="absolute"      ,						lowerCamelCase_				:			str=True      ,						lowerCamelCase_				:			Optional[Any]=None      ,						**lowerCamelCase_				:			Dict      ,						):

							'''simple docstring'''



							super().__init__(pad_token_id=lowerCamelCase_      ,						**lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			vocab_size
							SCREAMING_SNAKE_CASE :				Any		=			hidden_size
							SCREAMING_SNAKE_CASE :				Tuple		=			num_hidden_layers
							SCREAMING_SNAKE_CASE :				int		=			num_attention_heads
							SCREAMING_SNAKE_CASE :				Any		=			hidden_act
							SCREAMING_SNAKE_CASE :				str		=			intermediate_size
							SCREAMING_SNAKE_CASE :				List[str]		=			hidden_dropout_prob
							SCREAMING_SNAKE_CASE :				int		=			attention_probs_dropout_prob
							SCREAMING_SNAKE_CASE :				List[Any]		=			max_position_embeddings
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			type_vocab_size
							SCREAMING_SNAKE_CASE :				Optional[int]		=			initializer_range
							SCREAMING_SNAKE_CASE :				Tuple		=			layer_norm_eps
							SCREAMING_SNAKE_CASE :				str		=			position_embedding_type
							SCREAMING_SNAKE_CASE :				str		=			use_cache
							SCREAMING_SNAKE_CASE :				List[str]		=			classifier_dropout







class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""


					@property
					def lowerCamelCase_			(						self				:			Optional[Any]						):

							'''simple docstring'''



							if self.task == "multiple-choice":
									SCREAMING_SNAKE_CASE :				Tuple		=			{0: """batch""", 1: """choice""", 2: """sequence"""}
							else:
									SCREAMING_SNAKE_CASE :				Dict		=			{0: """batch""", 1: """sequence"""}
							return OrderedDict(
							    [
							        ("""input_ids""", dynamic_axis),
							        ("""attention_mask""", dynamic_axis),
							        ("""token_type_ids""", dynamic_axis),
							    ]						)










'''simple docstring'''




import unittest

from transformers import DonutProcessor


__UpperCAmelCase            =       """naver-clova-ix/donut-base"""




class      UpperCamelCase__					(					unittest.TestCase			):




					"""simple docstring"""


					def lowerCamelCase_			(						self				:			List[str]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Any		=			DonutProcessor.from_pretrained(lowerCamelCase_						)



					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Optional[int]		=			{
							    """name""": """John Doe""",
							    """age""": """99""",
							    """city""": """Atlanta""",
							    """state""": """GA""",
							    """zip""": """30301""",
							    """phone""": """123-4567""",
							    """nicknames""": [{"""nickname""": """Johnny"""}, {"""nickname""": """JD"""}],
							}

							SCREAMING_SNAKE_CASE :				List[Any]		=			(
							    """<s_name>John Doe</s_name><s_age>99</s_age><s_city>Atlanta</s_city>"""
							    """<s_state>GA</s_state><s_zip>30301</s_zip><s_phone>123-4567</s_phone>"""
							    """<s_nicknames><s_nickname>Johnny</s_nickname>"""
							    """<sep/><s_nickname>JD</s_nickname></s_nicknames>"""
							)
							SCREAMING_SNAKE_CASE :				List[Any]		=			self.processor.tokenajson(lowerCamelCase_						)

							self.assertDictEqual(lowerCamelCase_      ,						lowerCamelCase_						)



