





'''simple docstring'''







from collections import OrderedDict
from typing import Any, List, Mapping, Optional

from ... import PretrainedConfig, PreTrainedTokenizer
from ...onnx import OnnxConfig, PatchingSpec
from ...utils import TensorType, is_torch_available, logging


snake_case_  :							Union[str, Any]            =	logging.get_logger(__name__)

snake_case_  :							Dict            =	{
    "microsoft/layoutlm-base-uncased": (
        "https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/config.json"
    ),
    "microsoft/layoutlm-large-uncased": (
        "https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/config.json"
    ),
}


class        __a   (lowerCamelCase  ):
							__a       : Dict          =							"layoutlm"

							def __init__(				self				:  Tuple							,  __magic_name__				:  List[str]=3_05_22							,  __magic_name__				:  Tuple=7_68							,  __magic_name__				:  List[Any]=12							,  __magic_name__				:  Optional[int]=12							,  __magic_name__				:  Tuple=30_72							,  __magic_name__				:  Union[str, Any]="gelu"							,  __magic_name__				:  Tuple=0.1							,  __magic_name__				:  List[Any]=0.1							,  __magic_name__				:  Dict=5_12							,  __magic_name__				:  Optional[int]=2							,  __magic_name__				:  str=0.0_2							,  __magic_name__				:  str=1E-12							,  __magic_name__				:  List[str]=0							,  __magic_name__				:  Optional[int]="absolute"							,  __magic_name__				:  Tuple=True							,  __magic_name__				:  Any=10_24							,  **__magic_name__				:  int							,  )       ->							Tuple:







													"""simple docstring"""
													super().__init__(pad_token_id=__magic_name__							,  **__magic_name__ )
													UpperCAmelCase_      :   Dict      =	vocab_size
													UpperCAmelCase_      :   Tuple      =	hidden_size
													UpperCAmelCase_      :   int      =	num_hidden_layers
													UpperCAmelCase_      :   Optional[int]      =	num_attention_heads
													UpperCAmelCase_      :   Tuple      =	hidden_act
													UpperCAmelCase_      :   Optional[Any]      =	intermediate_size
													UpperCAmelCase_      :   Union[str, Any]      =	hidden_dropout_prob
													UpperCAmelCase_      :   Optional[Any]      =	attention_probs_dropout_prob
													UpperCAmelCase_      :   Union[str, Any]      =	max_position_embeddings
													UpperCAmelCase_      :   Any      =	type_vocab_size
													UpperCAmelCase_      :   Optional[Any]      =	initializer_range
													UpperCAmelCase_      :   Optional[Any]      =	layer_norm_eps
													UpperCAmelCase_      :   Optional[int]      =	position_embedding_type
													UpperCAmelCase_      :   int      =	use_cache
													UpperCAmelCase_      :   Optional[Any]      =	max_ad_position_embeddings





class        __a   (lowerCamelCase  ):

							def __init__(				self				:  List[str]							,  __magic_name__				:  PretrainedConfig							,  __magic_name__				:  str = "default"							,  __magic_name__				:  List[PatchingSpec] = None							,  )       ->							int:







													"""simple docstring"""
													super().__init__(__magic_name__							,  task=__magic_name__							,  patching_specs=__magic_name__ )
													UpperCAmelCase_      :   Optional[int]      =	config.max_ad_position_embeddings - 1

							@property
							def      UpperCAmelCase__						(				self				:  Dict )       ->							Mapping[str, Mapping[int, str]]:







													"""simple docstring"""
													return OrderedDict(
													    [
													        ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
													        ('''bbox''', {0: '''batch''', 1: '''sequence'''}),
													        ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
													        ('''token_type_ids''', {0: '''batch''', 1: '''sequence'''}),
													    ] )



							def      UpperCAmelCase__						(				self				:  Any							,  __magic_name__				:  PreTrainedTokenizer							,  __magic_name__				:  int = -1							,  __magic_name__				:  int = -1							,  __magic_name__				:  bool = False							,  __magic_name__				:  Optional[TensorType] = None							,  )       ->							Mapping[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_      :   Union[str, Any]      =	super().generate_dummy_inputs(
													    __magic_name__							,  batch_size=__magic_name__							,  seq_length=__magic_name__							,  is_pair=__magic_name__							,  framework=__magic_name__ )

													# Generate a dummy bbox
													UpperCAmelCase_      :   str      =	[48, 84, 73, 1_28]

													if not framework == TensorType.PYTORCH:
																			raise NotImplementedError('''Exporting LayoutLM to ONNX is currently only supported for PyTorch.''' )

													if not is_torch_available():
																			raise ValueError('''Cannot generate dummy inputs without PyTorch installed.''' )
													import torch

													UpperCAmelCase_    ,							UpperCAmelCase_      :   int      =	input_dict['''input_ids'''].shape
													UpperCAmelCase_      :   Any      =	torch.tensor([*[box] * seq_length] ).tile(__magic_name__							,  1							,  1 )
													return input_dict












'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case_  :							Any            =	{
    "configuration_dpr": ["DPR_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPRConfig"],
    "tokenization_dpr": [
        "DPRContextEncoderTokenizer",
        "DPRQuestionEncoderTokenizer",
        "DPRReaderOutput",
        "DPRReaderTokenizer",
    ],
}


try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					snake_case_  :							str            =	[
					    "DPRContextEncoderTokenizerFast",
					    "DPRQuestionEncoderTokenizerFast",
					    "DPRReaderTokenizerFast",
					]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					snake_case_  :							Optional[int]            =	[
					    "DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "DPRContextEncoder",
					    "DPRPretrainedContextEncoder",
					    "DPRPreTrainedModel",
					    "DPRPretrainedQuestionEncoder",
					    "DPRPretrainedReader",
					    "DPRQuestionEncoder",
					    "DPRReader",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					snake_case_  :							Dict            =	[
					    "TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TFDPRContextEncoder",
					    "TFDPRPretrainedContextEncoder",
					    "TFDPRPretrainedQuestionEncoder",
					    "TFDPRPretrainedReader",
					    "TFDPRQuestionEncoder",
					    "TFDPRReader",
					]


if TYPE_CHECKING:
					from .configuration_dpr import DPR_PRETRAINED_CONFIG_ARCHIVE_MAP, DPRConfig
					from .tokenization_dpr import (
					    DPRContextEncoderTokenizer,
					    DPRQuestionEncoderTokenizer,
					    DPRReaderOutput,
					    DPRReaderTokenizer,
					)

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_dpr_fast import (
										    DPRContextEncoderTokenizerFast,
										    DPRQuestionEncoderTokenizerFast,
										    DPRReaderTokenizerFast,
										)

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_dpr import (
										    DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    DPRContextEncoder,
										    DPRPretrainedContextEncoder,
										    DPRPreTrainedModel,
										    DPRPretrainedQuestionEncoder,
										    DPRPretrainedReader,
										    DPRQuestionEncoder,
										    DPRReader,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_dpr import (
										    TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFDPRContextEncoder,
										    TFDPRPretrainedContextEncoder,
										    TFDPRPretrainedQuestionEncoder,
										    TFDPRPretrainedReader,
										    TFDPRQuestionEncoder,
										    TFDPRReader,
										)

else:
					import sys

					snake_case_  :							List[str]            =	_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





