






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


snake_case_   :	List[str]							      =logging.get_logger(__name__)

snake_case_   :	List[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        a__      (	lowerCAmelCase__		):
		UpperCAmelCase_							:       Dict 					= 'layoutlmv2'






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






		@classmethod
		def 					_lowerCamelCase					(      self						)				->				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": [[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 					_lowerCamelCase					(      self						)				->				List[str]:
				__A    =							detectrona.config.get_cfg()
				for k, v in self.detectrona_config_args.items():
						__A    =							k.split("."						)
						__A    =							detectrona_config
						for attribute in attributes[:-1]:
								__A    =							getattr(lowercase__							, lowercase__						)
						setattr(lowercase__							, attributes[-1]							, lowercase__						)

				return detectrona_config


'''simple docstring'''




def _UpperCamelCase (							SCREAMING_SNAKE_CASE_				):
     return " ".join([word[::-1] for word in input_str.split()]				)


if __name__ == "__main__":
 import doctest

 doctest.testmod()




