


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


snake_case__  				=			logging.get_logger(__name__)

snake_case__  				=			{
    """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__	(   UpperCAmelCase__	):
				__lowerCAmelCase		=   """layoutlmv2"""
				def __init__(	self  ,   _UpperCAmelCase=3_0522  ,   _UpperCAmelCase=768  ,   _UpperCAmelCase=12  ,   _UpperCAmelCase=12  ,   _UpperCAmelCase=3072  ,   _UpperCAmelCase="gelu"  ,   _UpperCAmelCase=0.1  ,   _UpperCAmelCase=0.1  ,   _UpperCAmelCase=512  ,   _UpperCAmelCase=2  ,   _UpperCAmelCase=0.02  ,   _UpperCAmelCase=1E-1_2  ,   _UpperCAmelCase=0  ,   _UpperCAmelCase=1024  ,   _UpperCAmelCase=128  ,   _UpperCAmelCase=32  ,   _UpperCAmelCase=True  ,   _UpperCAmelCase=256  ,   _UpperCAmelCase=64  ,   _UpperCAmelCase=True  ,   _UpperCAmelCase=[7, 7, 256]  ,   _UpperCAmelCase=128  ,   _UpperCAmelCase=128  ,   _UpperCAmelCase=True  ,   _UpperCAmelCase=True  ,   _UpperCAmelCase=False  ,   _UpperCAmelCase=None  ,   **_UpperCAmelCase  ,   ):




										"""simple docstring"""




										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  ,   )
										__magic_name__					:				int				=   max_ad_position_embeddings
										__magic_name__					:				Any				=   max_rel_pos
										__magic_name__					:				Optional[Any]				=   rel_pos_bins
										__magic_name__					:				List[str]				=   fast_qkv
										__magic_name__					:				Optional[int]				=   max_rel_ad_pos
										__magic_name__					:				List[str]				=   rel_ad_pos_bins
										__magic_name__					:				str				=   convert_sync_batchnorm
										__magic_name__					:				List[Any]				=   image_feature_pool_shape
										__magic_name__					:				Any				=   coordinate_size
										__magic_name__					:				List[Any]				=   shape_size
										__magic_name__					:				List[Any]				=   has_relative_attention_bias
										__magic_name__					:				Any				=   has_spatial_attention_bias
										__magic_name__					:				List[str]				=   has_visual_segment_embedding
										__magic_name__					:				Optional[int]				=   (
										    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
										)
				@classmethod
				def 			UpperCamelCase_    (	self   ):




										"""simple docstring"""




										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 			UpperCamelCase_    (	self   ):




										"""simple docstring"""




										__magic_name__					:				str				=   detectrona.config.get_cfg()
										for k, v in self.detectrona_config_args.items():
																__magic_name__					:				Dict				=   k.split('.'   )
																__magic_name__					:				Optional[int]				=   detectrona_config
																for attribute in attributes[:-1]:
																						__magic_name__					:				Union[str, Any]				=   getattr(__lowercase  ,   __lowercase   )
																setattr(__lowercase  ,   attributes[-1]  ,   __lowercase   )

										return detectrona_config






import numpy as np

_UpperCAmelCase      :	int  =[
    ["""a""", """b""", """c""", """d""", """e"""],
    ["""f""", """g""", """h""", """i""", """k"""],
    ["""l""", """m""", """n""", """o""", """p"""],
    ["""q""", """r""", """s""", """t""", """u"""],
    ["""v""", """w""", """x""", """y""", """z"""],
]







class 					snake_case__:







						'''simple docstring'''




						def __init__(					self				)       ->     None:
										lowerCAmelCase_			:   List[Any]     					=					np.array(__lowercase				)




						def     lowercase_			(					self ,    __lowercase				)       ->     np.ndarray:
										lowerCAmelCase_					,	lowerCAmelCase_			:   List[str]     					=					np.where(letter == self.SQUARE				)
										lowerCAmelCase_			:   Union[str, Any]     					=					np.concatenate([indexa + 1, indexa + 1]				)
										return indexes




						def     lowercase_			(					self ,    __lowercase ,    __lowercase				)       ->     str:
										return self.SQUARE[indexa - 1, indexa - 1]




						def     lowercase_			(					self ,    __lowercase				)       ->     str:
										lowerCAmelCase_			:   Dict     					=					message.lower()
										lowerCAmelCase_			:   Any     					=					message.replace('''j''' ,    '''i'''				)

										lowerCAmelCase_			:   Optional[Any]     					=					''''''
										for letter_index in range(len(__lowercase				)				):
														if message[letter_index] != " ":
																		lowerCAmelCase_			:   Optional[Any]     					=					self.letter_to_numbers(message[letter_index]				)
																		lowerCAmelCase_			:   List[Any]     					=					encoded_message + str(numbers[0]				) + str(numbers[1]				)
														elif message[letter_index] == " ":
																		lowerCAmelCase_			:   Optional[Any]     					=					encoded_message + ''' '''

										return encoded_message




						def     lowercase_			(					self ,    __lowercase				)       ->     str:
										lowerCAmelCase_			:   List[str]     					=					message.replace(''' ''' ,    '''  '''				)
										lowerCAmelCase_			:   Union[str, Any]     					=					''''''
										for numbers_index in range(int(len(__lowercase				) / 2				)				):
														if message[numbers_index * 2] != " ":
																		lowerCAmelCase_			:   Any     					=					message[numbers_index * 2]
																		lowerCAmelCase_			:   Dict     					=					message[numbers_index * 2 + 1]

																		lowerCAmelCase_			:   Dict     					=					self.numbers_to_letter(int(__lowercase				) ,    int(__lowercase				)				)
																		lowerCAmelCase_			:   Tuple     					=					decoded_message + letter
														elif message[numbers_index * 2] == " ":
																		lowerCAmelCase_			:   List[str]     					=					decoded_message + ''' '''

										return decoded_message