

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


__A	:   Any	=					logging.get_logger(__name__)

__A	:   str	=					{
    '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 			_SCREAMING_SNAKE_CASE      (  lowerCAmelCase__):
						_UpperCamelCase:Any	=		"layoutlmv2"







						def __init__(			self     ,						_SCREAMING_SNAKE_CASE=3_0522     ,						_SCREAMING_SNAKE_CASE=768     ,						_SCREAMING_SNAKE_CASE=12     ,						_SCREAMING_SNAKE_CASE=12     ,						_SCREAMING_SNAKE_CASE=3072     ,						_SCREAMING_SNAKE_CASE="gelu"     ,						_SCREAMING_SNAKE_CASE=0.1     ,						_SCREAMING_SNAKE_CASE=0.1     ,						_SCREAMING_SNAKE_CASE=512     ,						_SCREAMING_SNAKE_CASE=2     ,						_SCREAMING_SNAKE_CASE=0.0_2     ,						_SCREAMING_SNAKE_CASE=1E-12     ,						_SCREAMING_SNAKE_CASE=0     ,						_SCREAMING_SNAKE_CASE=1024     ,						_SCREAMING_SNAKE_CASE=128     ,						_SCREAMING_SNAKE_CASE=32     ,						_SCREAMING_SNAKE_CASE=True     ,						_SCREAMING_SNAKE_CASE=256     ,						_SCREAMING_SNAKE_CASE=64     ,						_SCREAMING_SNAKE_CASE=True     ,						_SCREAMING_SNAKE_CASE=[7, 7, 256]     ,						_SCREAMING_SNAKE_CASE=128     ,						_SCREAMING_SNAKE_CASE=128     ,						_SCREAMING_SNAKE_CASE=True     ,						_SCREAMING_SNAKE_CASE=True     ,						_SCREAMING_SNAKE_CASE=False     ,						_SCREAMING_SNAKE_CASE=None     ,						**_SCREAMING_SNAKE_CASE     ,						)->							List[str]:
													super().__init__(
													    vocab_size=_SCREAMING_SNAKE_CASE     ,						hidden_size=_SCREAMING_SNAKE_CASE     ,						num_hidden_layers=_SCREAMING_SNAKE_CASE     ,						num_attention_heads=_SCREAMING_SNAKE_CASE     ,						intermediate_size=_SCREAMING_SNAKE_CASE     ,						hidden_act=_SCREAMING_SNAKE_CASE     ,						hidden_dropout_prob=_SCREAMING_SNAKE_CASE     ,						attention_probs_dropout_prob=_SCREAMING_SNAKE_CASE     ,						max_position_embeddings=_SCREAMING_SNAKE_CASE     ,						type_vocab_size=_SCREAMING_SNAKE_CASE     ,						initializer_range=_SCREAMING_SNAKE_CASE     ,						layer_norm_eps=_SCREAMING_SNAKE_CASE     ,						pad_token_id=_SCREAMING_SNAKE_CASE     ,						**_SCREAMING_SNAKE_CASE     ,						)
													lowerCamelCase_								=max_ad_position_embeddings
													lowerCamelCase_								=max_rel_pos
													lowerCamelCase_								=rel_pos_bins
													lowerCamelCase_								=fast_qkv
													lowerCamelCase_								=max_rel_ad_pos
													lowerCamelCase_								=rel_ad_pos_bins
													lowerCamelCase_								=convert_sync_batchnorm
													lowerCamelCase_								=image_feature_pool_shape
													lowerCamelCase_								=coordinate_size
													lowerCamelCase_								=shape_size
													lowerCamelCase_								=has_relative_attention_bias
													lowerCamelCase_								=has_spatial_attention_bias
													lowerCamelCase_								=has_visual_segment_embedding
													lowerCamelCase_								=(
													    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
													)







						@classmethod
						def        _snake_case				(			self							)->							Tuple:
													return {
													    "MODEL.MASK_ON": True,
													    "MODEL.PIXEL_STD": [5_7.3_7_5, 5_7.1_2_0, 5_8.3_9_5],
													    "MODEL.BACKBONE.NAME": "build_resnet_fpn_backbone",
													    "MODEL.FPN.IN_FEATURES": ["res2", "res3", "res4", "res5"],
													    "MODEL.ANCHOR_GENERATOR.SIZES": [[32], [64], [128], [256], [512]],
													    "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
													    "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 2000,
													    "MODEL.RPN.PRE_NMS_TOPK_TEST": 1000,
													    "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1000,
													    "MODEL.POST_NMS_TOPK_TEST": 1000,
													    "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": 14,
													    "MODEL.ROI_MASK_HEAD.NAME": "MaskRCNNConvUpsampleHead",
													    "MODEL.ROI_MASK_HEAD.NUM_CONV": 4,
													    "MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION": 7,
													    "MODEL.RESNETS.DEPTH": 101,
													    "MODEL.RESNETS.SIZES": [[32], [64], [128], [256], [512]],
													    "MODEL.RESNETS.ASPECT_RATIOS": [[0.5, 1.0, 2.0]],
													    "MODEL.RESNETS.OUT_FEATURES": ["res2", "res3", "res4", "res5"],
													    "MODEL.RESNETS.NUM_GROUPS": 32,
													    "MODEL.RESNETS.WIDTH_PER_GROUP": 8,
													    "MODEL.RESNETS.STRIDE_IN_1X1": False,
													}







						def        _snake_case				(			self							)->							Optional[Any]:
													lowerCamelCase_								=detectrona.config.get_cfg()
													for k, v in self.detectrona_config_args.items():
																				lowerCamelCase_								=k.split("""."""							)
																				lowerCamelCase_								=detectrona_config
																				for attribute in attributes[:-1]:
																											lowerCamelCase_								=getattr(_SCREAMING_SNAKE_CASE     ,						_SCREAMING_SNAKE_CASE							)
																				setattr(_SCREAMING_SNAKE_CASE     ,						attributes[-1]     ,						_SCREAMING_SNAKE_CASE							)

													return detectrona_config



def        __UpperCamelCase     (      _A					:							str		)				->int:



							"""simple docstring"""
							lowerCamelCase_								=lowerCamelCase_								=0
							for letter in data:
														lowerCamelCase_								=(hash_ << 4) + ord(_A		)
														lowerCamelCase_								=hash_ & 0XF0000000
														if x != 0:
																					hash_ ^= x >> 24
														hash_ &= ~x
							return hash_


if __name__ == "__main__":
	import doctest

	doctest.testmod()
