


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


UpperCAmelCase			=    logging.get_logger(__name__)

UpperCAmelCase			=    {
    """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 lowerCAmelCase_						( lowerCamelCase__       ):

 '''simple docstring'''

 __snake_case												=  '''layoutlmv2'''



 def __init__(	self		,      _UpperCAmelCase=3_05_22		,      _UpperCAmelCase=7_68		,      _UpperCAmelCase=12		,      _UpperCAmelCase=12		,      _UpperCAmelCase=30_72		,      _UpperCAmelCase="gelu"		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=5_12		,      _UpperCAmelCase=2		,      _UpperCAmelCase=0.02		,      _UpperCAmelCase=1E-12		,      _UpperCAmelCase=0		,      _UpperCAmelCase=10_24		,      _UpperCAmelCase=1_28		,      _UpperCAmelCase=32		,      _UpperCAmelCase=True		,      _UpperCAmelCase=2_56		,      _UpperCAmelCase=64		,      _UpperCAmelCase=True		,      _UpperCAmelCase=[7, 7, 2_56]		,      _UpperCAmelCase=1_28		,      _UpperCAmelCase=1_28		,      _UpperCAmelCase=True		,      _UpperCAmelCase=True		,      _UpperCAmelCase=False		,      _UpperCAmelCase=None		,      **_UpperCAmelCase		,      ):
       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 						UpperCamelCase__     (	self					):
       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], [1_28], [2_56], [5_12]],
           "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
           "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 20_00,
           "MODEL.RPN.PRE_NMS_TOPK_TEST": 10_00,
           "MODEL.RPN.POST_NMS_TOPK_TRAIN": 10_00,
           "MODEL.POST_NMS_TOPK_TEST": 10_00,
           "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": 1_01,
           "MODEL.RESNETS.SIZES": [[32], [64], [1_28], [2_56], [5_12]],
           "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					):
       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







import re


def      lowerCamelCase__	(   lowercase ):

  """simple docstring"""






  def docstring_decorator(lowercase ):
    SCREAMING_SNAKE_CASE				:					List[Any]		  =			fn.__doc__
    SCREAMING_SNAKE_CASE				:					Tuple		  =			func_doc.split("\n" )
    SCREAMING_SNAKE_CASE				:					Tuple		  =			0
    while i < len(lowercase ) and re.search(R"^\s*Examples?:\s*$"  ,   lines[i] ) is None:
      i += 1
    if i < len(lowercase ):
      SCREAMING_SNAKE_CASE				:					int		  =			example_docstring
      SCREAMING_SNAKE_CASE				:					Tuple		  =			"\n".join(lowercase )
    else:
      raise ValueError(
          F'''The function {fn} should have an empty \'Examples:\' in its docstring as placeholder, '''
          F'''current docstring is:\n{func_doc}''' )
    SCREAMING_SNAKE_CASE				:					int		  =			func_doc
    return fn

  return docstring_decorator






