

from ...configuration_utils import PretrainedConfig
from ...utils import is_detectrona_available, logging


lowerCAmelCase_	     =     logging.get_logger(__name__)

lowerCAmelCase_	     =     {
    '''layoutlmv2-base-uncased''': '''https://huggingface.co/microsoft/layoutlmv2-base-uncased/resolve/main/config.json''',
    '''layoutlmv2-large-uncased''': '''https://huggingface.co/microsoft/layoutlmv2-large-uncased/resolve/main/config.json''',
    # See all LayoutLMv2 models at https://huggingface.co/models?filter=layoutlmv2
}

# soft dependency
if is_detectrona_available():
					import detectrona





class      snake_case_       (		__A ):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE					:       Optional[int]						      =    "layoutlmv2"







			def __init__(					self			:    Optional[Any]							,       _UpperCamelCase			:    Union[str, Any]=3_0_5_2_2							,       _UpperCamelCase			:    List[str]=7_6_8							,       _UpperCamelCase			:    Any=1_2							,       _UpperCamelCase			:    Any=1_2							,       _UpperCamelCase			:    List[Any]=3_0_7_2							,       _UpperCamelCase			:    Tuple="gelu"							,       _UpperCamelCase			:    Optional[int]=0.1							,       _UpperCamelCase			:    Optional[Any]=0.1							,       _UpperCamelCase			:    Any=5_1_2							,       _UpperCamelCase			:    Union[str, Any]=2							,       _UpperCamelCase			:    int=0.02							,       _UpperCamelCase			:    Optional[Any]=1e-12							,       _UpperCamelCase			:    Union[str, Any]=0							,       _UpperCamelCase			:    List[Any]=1_0_2_4							,       _UpperCamelCase			:    Tuple=1_2_8							,       _UpperCamelCase			:    Optional[Any]=3_2							,       _UpperCamelCase			:    Optional[int]=True							,       _UpperCamelCase			:    Any=2_5_6							,       _UpperCamelCase			:    Dict=6_4							,       _UpperCamelCase			:    List[Any]=True							,       _UpperCamelCase			:    int=[7, 7, 2_5_6]							,       _UpperCamelCase			:    Optional[int]=1_2_8							,       _UpperCamelCase			:    List[str]=1_2_8							,       _UpperCamelCase			:    Optional[int]=True							,       _UpperCamelCase			:    Optional[int]=True							,       _UpperCamelCase			:    Optional[Any]=False							,       _UpperCamelCase			:    List[Any]=None							,       **_UpperCamelCase			:    List[str]							,       )				->Tuple:
									super().__init__(
									    vocab_size=_UpperCamelCase							,       hidden_size=_UpperCamelCase							,       num_hidden_layers=_UpperCamelCase							,       num_attention_heads=_UpperCamelCase							,       intermediate_size=_UpperCamelCase							,       hidden_act=_UpperCamelCase							,       hidden_dropout_prob=_UpperCamelCase							,       attention_probs_dropout_prob=_UpperCamelCase							,       max_position_embeddings=_UpperCamelCase							,       type_vocab_size=_UpperCamelCase							,       initializer_range=_UpperCamelCase							,       layer_norm_eps=_UpperCamelCase							,       pad_token_id=_UpperCamelCase							,       **_UpperCamelCase							,       )
									snake_case_       =     max_ad_position_embeddings
									snake_case_       =     max_rel_pos
									snake_case_       =     rel_pos_bins
									snake_case_       =     fast_qkv
									snake_case_       =     max_rel_ad_pos
									snake_case_       =     rel_ad_pos_bins
									snake_case_       =     convert_sync_batchnorm
									snake_case_       =     image_feature_pool_shape
									snake_case_       =     coordinate_size
									snake_case_       =     shape_size
									snake_case_       =     has_relative_attention_bias
									snake_case_       =     has_spatial_attention_bias
									snake_case_       =     has_visual_segment_embedding
									snake_case_       =     (
									    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
									)







			@classmethod
			def     snake_case__(					self			:    Union[str, Any]							)				->str:
									return {
									    "MODEL.MASK_ON": True,
									    "MODEL.PIXEL_STD": [57.375, 57.120, 58.395],
									    "MODEL.BACKBONE.NAME": "build_resnet_fpn_backbone",
									    "MODEL.FPN.IN_FEATURES": ["res2", "res3", "res4", "res5"],
									    "MODEL.ANCHOR_GENERATOR.SIZES": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
									    "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
									    "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 2_0_0_0,
									    "MODEL.RPN.PRE_NMS_TOPK_TEST": 1_0_0_0,
									    "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1_0_0_0,
									    "MODEL.POST_NMS_TOPK_TEST": 1_0_0_0,
									    "MODEL.ROI_HEADS.NAME": "StandardROIHeads",
									    "MODEL.ROI_HEADS.NUM_CLASSES": 5,
									    "MODEL.ROI_HEADS.IN_FEATURES": ["p2", "p3", "p4", "p5"],
									    "MODEL.ROI_BOX_HEAD.NAME": "FastRCNNConvFCHead",
									    "MODEL.ROI_BOX_HEAD.NUM_FC": 2,
									    "MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION": 1_4,
									    "MODEL.ROI_MASK_HEAD.NAME": "MaskRCNNConvUpsampleHead",
									    "MODEL.ROI_MASK_HEAD.NUM_CONV": 4,
									    "MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION": 7,
									    "MODEL.RESNETS.DEPTH": 1_0_1,
									    "MODEL.RESNETS.SIZES": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
									    "MODEL.RESNETS.ASPECT_RATIOS": [[0.5, 1.0, 2.0]],
									    "MODEL.RESNETS.OUT_FEATURES": ["res2", "res3", "res4", "res5"],
									    "MODEL.RESNETS.NUM_GROUPS": 3_2,
									    "MODEL.RESNETS.WIDTH_PER_GROUP": 8,
									    "MODEL.RESNETS.STRIDE_IN_1X1": False,
									}







			def     snake_case__(					self			:    List[Any]							)				->int:
									snake_case_       =     detectrona.config.get_cfg()
									for k, v in self.detectrona_config_args.items():
															snake_case_       =     k.split('''.'''							)
															snake_case_       =     detectrona_config
															for attribute in attributes[:-1]:
																					snake_case_       =     getattr(_UpperCamelCase							,       _UpperCamelCase							)
															setattr(_UpperCamelCase							,       attributes[-1]							,       _UpperCamelCase							)

									return detectrona_config


def   __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__	):
						snake_case_       =     5381
						for x in s:
												snake_case_       =     ((hash_value << 5) + hash_value) + ord(SCREAMING_SNAKE_CASE__	)
						return hash_value & 0xFF_FF_FF_FF