




"""simple docstring"""




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

from packaging import version

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


if TYPE_CHECKING:
					from ...processing_utils import ProcessorMixin
					from ...utils import TensorType


UpperCamelCase__         =      logging.get_logger(__name__)

UpperCamelCase__         =      {
    """microsoft/layoutlmv3-base""": """https://huggingface.co/microsoft/layoutlmv3-base/resolve/main/config.json""",
}
class       a__   ( snake_case__				):
						_a							:   str =   """layoutlmv3"""






						def __init__(       self		,      _A=5_0_2_6_5		,      _A=7_6_8		,      _A=1_2		,      _A=1_2		,      _A=3_0_7_2		,      _A="gelu"		,      _A=0.1		,      _A=0.1		,      _A=5_1_2		,      _A=2		,      _A=0.02		,      _A=1E-5		,      _A=1		,      _A=0		,      _A=2		,      _A=1_0_2_4		,      _A=1_2_8		,      _A=1_2_8		,      _A=True		,      _A=3_2		,      _A=1_2_8		,      _A=6_4		,      _A=2_5_6		,      _A=True		,      _A=True		,      _A=True		,      _A=2_2_4		,      _A=3		,      _A=1_6		,      _A=None		,      **_A		,      ):




											"""simple docstring"""



											super().__init__(
											    vocab_size=_A		,      hidden_size=_A		,      num_hidden_layers=_A		,      num_attention_heads=_A		,      intermediate_size=_A		,      hidden_act=_A		,      hidden_dropout_prob=_A		,      attention_probs_dropout_prob=_A		,      max_position_embeddings=_A		,      type_vocab_size=_A		,      initializer_range=_A		,      layer_norm_eps=_A		,      pad_token_id=_A		,      bos_token_id=_A		,      eos_token_id=_A		,      **_A		,      )
											__lowerCAmelCase           =	max_ad_position_embeddings
											__lowerCAmelCase           =	coordinate_size
											__lowerCAmelCase           =	shape_size
											__lowerCAmelCase           =	has_relative_attention_bias
											__lowerCAmelCase           =	rel_pos_bins
											__lowerCAmelCase           =	max_rel_pos
											__lowerCAmelCase           =	has_spatial_attention_bias
											__lowerCAmelCase           =	rel_ad_pos_bins
											__lowerCAmelCase           =	max_rel_ad_pos
											__lowerCAmelCase           =	text_embed
											__lowerCAmelCase           =	visual_embed
											__lowerCAmelCase           =	input_size
											__lowerCAmelCase           =	num_channels
											__lowerCAmelCase           =	patch_size
											__lowerCAmelCase           =	classifier_dropout






class       a__   ( snake_case__				):
						_a							:   Tuple =   version.parse("""1.12"""				)






						@property
						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											if self.task in ["question-answering", "sequence-classification"]:
																return OrderedDict(
																    [
																        ("input_ids", {0: "batch", 1: "sequence"}),
																        ("attention_mask", {0: "batch", 1: "sequence"}),
																        ("bbox", {0: "batch", 1: "sequence"}),
																        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
																    ]      )
											else:
																return OrderedDict(
																    [
																        ("input_ids", {0: "batch", 1: "sequence"}),
																        ("bbox", {0: "batch", 1: "sequence"}),
																        ("attention_mask", {0: "batch", 1: "sequence"}),
																        ("pixel_values", {0: "batch", 1: "num_channels"}),
																    ]      )






						@property
						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											return 1E-5






						@property
						def     __SCREAMING_SNAKE_CASE(       self      ):




											"""simple docstring"""



											return 1_2






						def     __SCREAMING_SNAKE_CASE(       self		,      _A		,      _A = -1		,      _A = -1		,      _A = False		,      _A = None		,      _A = 3		,      _A = 4_0		,      _A = 4_0		,      ):




											"""simple docstring"""



											setattr(processor.image_processor		,      "apply_ocr"		,      _A      )

											# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
											__lowerCAmelCase           =	compute_effective_axis_dimension(
											    _A		,      fixed_dimension=OnnxConfig.default_fixed_batch		,      num_token_to_add=0      )
											# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
											__lowerCAmelCase           =	processor.tokenizer.num_special_tokens_to_add(_A      )
											__lowerCAmelCase           =	compute_effective_axis_dimension(
											    _A		,      fixed_dimension=OnnxConfig.default_fixed_sequence		,      num_token_to_add=_A      )
											# Generate dummy inputs according to compute batch and sequence
											__lowerCAmelCase           =	[[" ".join([processor.tokenizer.unk_token]      ) * seq_length]] * batch_size

											# Generate dummy bounding boxes
											__lowerCAmelCase           =	[[[4_8, 8_4, 7_3, 1_2_8]]] * batch_size

											# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
											# batch_size = compute_effective_axis_dimension(batch_size, fixed_dimension=OnnxConfig.default_fixed_batch)
											__lowerCAmelCase           =	self._generate_dummy_images(_A		,      _A		,      _A		,      _A      )

											__lowerCAmelCase           =	dict(
											    processor(
											        _A		,      text=_A		,      boxes=_A		,      return_tensors=_A		,      )      )

											return inputs










from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase__         =      logging.get_logger(__name__)

UpperCamelCase__         =      {
    """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""",
}
class       a__   ( snake_case__				):
						_a							:   Dict =   """mgp-str"""






						def __init__(       self		,      _A=[3_2, 1_2_8]		,      _A=4		,      _A=3		,      _A=2_7		,      _A=3_8		,      _A=5_0_2_5_7		,      _A=3_0_5_2_2		,      _A=7_6_8		,      _A=1_2		,      _A=1_2		,      _A=4.0		,      _A=True		,      _A=False		,      _A=1E-5		,      _A=0.0		,      _A=0.0		,      _A=0.0		,      _A=False		,      _A=0.02		,      **_A		,      ):




											"""simple docstring"""



											super().__init__(**_A      )

											__lowerCAmelCase           =	image_size
											__lowerCAmelCase           =	patch_size
											__lowerCAmelCase           =	num_channels
											__lowerCAmelCase           =	max_token_length
											__lowerCAmelCase           =	num_character_labels
											__lowerCAmelCase           =	num_bpe_labels
											__lowerCAmelCase           =	num_wordpiece_labels
											__lowerCAmelCase           =	hidden_size
											__lowerCAmelCase           =	num_hidden_layers
											__lowerCAmelCase           =	num_attention_heads
											__lowerCAmelCase           =	mlp_ratio
											__lowerCAmelCase           =	distilled
											__lowerCAmelCase           =	layer_norm_eps
											__lowerCAmelCase           =	drop_rate
											__lowerCAmelCase           =	qkv_bias
											__lowerCAmelCase           =	attn_drop_rate
											__lowerCAmelCase           =	drop_path_rate
											__lowerCAmelCase           =	output_aa_attentions
											__lowerCAmelCase           =	initializer_range




