






'''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


UpperCamelCase__       =	logging.get_logger(__name__)

UpperCamelCase__       =	{
    '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 				_UpperCAmelCase  (						__lowerCAmelCase	):
    __lowerCamelCase:      int										=			'''layoutlm'''




    def __init__(	self     :				List[str]     ,   a     :				Union[str, Any]=3_0_5_2_2     ,   a     :				Any=7_6_8     ,   a     :				int=1_2     ,   a     :				List[Any]=1_2     ,   a     :				Union[str, Any]=3_0_7_2     ,   a     :				Union[str, Any]="gelu"     ,   a     :				Union[str, Any]=0.1     ,   a     :				Union[str, Any]=0.1     ,   a     :				Union[str, Any]=5_1_2     ,   a     :				str=2     ,   a     :				Optional[Any]=0.02     ,   a     :				str=1e-12     ,   a     :				Union[str, Any]=0     ,   a     :				List[Any]="absolute"     ,   a     :				str=True     ,   a     :				str=1_0_2_4     ,   **a     :				Any     ,   ):






       '''simple docstring'''






       super().__init__(pad_token_id=_lowerCamelCase     ,   **_lowerCamelCase	)
       lowercase_		:			str							=   vocab_size
       lowercase_		:			int							=   hidden_size
       lowercase_		:			Dict							=   num_hidden_layers
       lowercase_		:			Optional[Any]							=   num_attention_heads
       lowercase_		:			str							=   hidden_act
       lowercase_		:			Any							=   intermediate_size
       lowercase_		:			List[Any]							=   hidden_dropout_prob
       lowercase_		:			Union[str, Any]							=   attention_probs_dropout_prob
       lowercase_		:			List[Any]							=   max_position_embeddings
       lowercase_		:			Dict							=   type_vocab_size
       lowercase_		:			Union[str, Any]							=   initializer_range
       lowercase_		:			int							=   layer_norm_eps
       lowercase_		:			Union[str, Any]							=   position_embedding_type
       lowercase_		:			List[str]							=   use_cache
       lowercase_		:			List[str]							=   max_ad_position_embeddings


class 				_UpperCAmelCase  (						__lowerCAmelCase	):




    def __init__(	self     :				int     ,   a     :				List[str]     ,   a     :				Dict = "default"     ,   a     :				int = None     ,   ):






       '''simple docstring'''






       super().__init__(_lowerCamelCase     ,   task=_lowerCamelCase     ,   patching_specs=_lowerCamelCase	)
       lowercase_		:			Optional[int]							=   config.max_ad_position_embeddings - 1




    @property
    def  lowerCAmelCase__ (	self     :				Union[str, Any]	):






       '''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  lowerCAmelCase__ (	self     :				Optional[int]     ,   a     :				Optional[Any]     ,   a     :				Union[str, Any] = -1     ,   a     :				Optional[Any] = -1     ,   a     :				int = False     ,   a     :				List[Any] = None     ,   ):






       '''simple docstring'''






       lowercase_		:			Optional[Any]							=   super().generate_dummy_inputs(
           _lowerCamelCase     ,   batch_size=_lowerCamelCase     ,   seq_length=_lowerCamelCase     ,   is_pair=_lowerCamelCase     ,   framework=_lowerCamelCase	)

       # Generate a dummy bbox
       lowercase_		:			Optional[Any]							=   [4_8, 8_4, 7_3, 1_2_8]

       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

       lowercase_			,						lowercase_		:			Optional[Any]							=   input_dict["input_ids"].shape
       lowercase_		:			List[str]							=   torch.tensor([*[box] * seq_length]	).tile(_lowerCamelCase     ,   1     ,   1	)
       return input_dict





"""simple docstring"""


from __future__ import annotations





def 			lowerCamelCase_ (					__lowerCAmelCase				)							->					int | float:




						'''simple docstring'''



						if len(__lowerCAmelCase				) == 0:
												raise ValueError("find_max() arg is an empty sequence"				)
						lowerCamelCase__					=nums[0]
						for x in nums:
												if x > max_num:
																		lowerCamelCase__					=x
						return max_num


if __name__ == "__main__":
	import doctest

	doctest.testmod(verbose=True)


