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


lowercase_						    =					logging.get_logger(__name__)

lowercase_						    =					{
    "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_						):
 """simple docstring"""




 UpperCamelCase_						:     int				   =    """layoutlm"""




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



      """simple docstring"""

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



class 		UpperCAmelCase_	(lowerCamelCase_						):
 """simple docstring"""




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



      """simple docstring"""

      super().__init__(a_     ,   task=a_     ,   patching_specs=a_ )
      UpperCAmelCase_						:    Optional[Any]    					=  config.max_ad_position_embeddings - 1




 @property
 def   a      ( self       : Optional[int] )->					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   a      ( self       : List[str]     ,   a_       : PreTrainedTokenizer     ,   a_       : int = -1     ,   a_       : int = -1     ,   a_       : bool = False     ,   a_       : Optional[TensorType] = None     ,   )->					Mapping[str, Any]:



      """simple docstring"""

      UpperCAmelCase_						:    Tuple    					=  super().generate_dummy_inputs(
          a_     ,   batch_size=a_     ,   seq_length=a_     ,   is_pair=a_     ,   framework=a_ )

      # Generate a dummy bbox
      UpperCAmelCase_						:    List[Any]    					=  [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_						:    Any    					=  input_dict["""input_ids"""].shape
      UpperCAmelCase_						:    int    					=  torch.tensor([*[box] * seq_length] ).tile(a_     ,   1     ,   1 )
      return input_dict



"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase_						    =					{"configuration_visual_bert": ["VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VisualBertConfig"]}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowercase_						    =					[
           "VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
           "VisualBertForMultipleChoice",
           "VisualBertForPreTraining",
           "VisualBertForQuestionAnswering",
           "VisualBertForRegionToPhraseAlignment",
           "VisualBertForVisualReasoning",
           "VisualBertLayer",
           "VisualBertModel",
           "VisualBertPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_visual_bert import (
                  VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  VisualBertForMultipleChoice,
                  VisualBertForPreTraining,
                  VisualBertForQuestionAnswering,
                  VisualBertForRegionToPhraseAlignment,
                  VisualBertForVisualReasoning,
                  VisualBertLayer,
                  VisualBertModel,
                  VisualBertPreTrainedModel,
              )


else:
       import sys

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

