



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


__snake_case		:List[Any] 						=	logging.get_logger(__name__)

__snake_case		:List[Any] 						=	{
    '''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			(      __UpperCAmelCase       ):
       UpperCamelCase__    :       List[str]		   =		'''layoutlmv2'''



       def __init__(						self				:	Dict	,						__SCREAMING_SNAKE_CASE				:	List[Any]=30_522	,						__SCREAMING_SNAKE_CASE				:	str=768	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=12	,						__SCREAMING_SNAKE_CASE				:	str=12	,						__SCREAMING_SNAKE_CASE				:	List[str]=3_072	,						__SCREAMING_SNAKE_CASE				:	str="gelu"	,						__SCREAMING_SNAKE_CASE				:	Tuple=0.1	,						__SCREAMING_SNAKE_CASE				:	Tuple=0.1	,						__SCREAMING_SNAKE_CASE				:	Tuple=512	,						__SCREAMING_SNAKE_CASE				:	Tuple=2	,						__SCREAMING_SNAKE_CASE				:	Any=0.02	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=1E-12	,						__SCREAMING_SNAKE_CASE				:	List[Any]=0	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=1_024	,						__SCREAMING_SNAKE_CASE				:	Dict=128	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=32	,						__SCREAMING_SNAKE_CASE				:	Dict=True	,						__SCREAMING_SNAKE_CASE				:	List[Any]=256	,						__SCREAMING_SNAKE_CASE				:	Dict=64	,						__SCREAMING_SNAKE_CASE				:	str=True	,						__SCREAMING_SNAKE_CASE				:	str=[7, 7, 256]	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=128	,						__SCREAMING_SNAKE_CASE				:	Tuple=128	,						__SCREAMING_SNAKE_CASE				:	Dict=True	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=True	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=False	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=None	,						**__SCREAMING_SNAKE_CASE				:	Any	,						):


           '''simple docstring'''

           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	,						)
           __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):


           '''simple docstring'''

           return {
               "MODEL.MASK_ON": True,
               "MODEL.PIXEL_STD": [57.3_75, 57.1_20, 58.3_95],
               "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": 2_000,
               "MODEL.RPN.PRE_NMS_TOPK_TEST": 1_000,
               "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1_000,
               "MODEL.POST_NMS_TOPK_TEST": 1_000,
               "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				:	str):


           '''simple docstring'''

           __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(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE)
               setattr(__SCREAMING_SNAKE_CASE	,						attributes[-1]	,						__SCREAMING_SNAKE_CASE)

           return detectrona_config










def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 9 / 5) + 32  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(float(_UpperCAmelCase							) + 2_73.15  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 9 / 5) + 4_91.67  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) - 32) * 5 / 9  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(((float(_UpperCAmelCase							) - 32) * 5 / 9) + 2_73.15  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(float(_UpperCAmelCase							) + 4_59.67  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(float(_UpperCAmelCase							) - 2_73.15  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(((float(_UpperCAmelCase							) - 2_73.15) * 9 / 5) + 32  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 9 / 5)  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) - 4_91.67) * 5 / 9  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round(float(_UpperCAmelCase							) - 4_59.67  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 5 / 9)  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 1.25 + 2_73.15)  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 2.25 + 32)  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 1.25)  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase = 2							):
    return round((float(_UpperCAmelCase							) * 2.25 + 32 + 4_59.67)  ,					_UpperCAmelCase							)


if __name__ == "__main__":
 import doctest

 doctest.testmod()





