






"""simple docstring"""





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 		_a       (						lowercase_   ):





			'''simple docstring'''






			UpperCamelCase__      					=    """layoutlmv2"""





			def __init__(   self			,				UpperCAmelCase_=30_522			,				UpperCAmelCase_=768			,				UpperCAmelCase_=12			,				UpperCAmelCase_=12			,				UpperCAmelCase_=3_072			,				UpperCAmelCase_="gelu"			,				UpperCAmelCase_=0.1			,				UpperCAmelCase_=0.1			,				UpperCAmelCase_=512			,				UpperCAmelCase_=2			,				UpperCAmelCase_=0.02			,				UpperCAmelCase_=1E-1_2			,				UpperCAmelCase_=0			,				UpperCAmelCase_=1_024			,				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_			,				)	-> Dict:




										'''simple docstring'''




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





			@classmethod
			def __lowercase    (   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 __lowercase    (   self)	-> int:




										'''simple docstring'''




										lowercase__:    Union[str, Any]        =      detectrona.config.get_cfg()
										for k, v in self.detectrona_config_args.items():
																	lowercase__:    List[str]        =      k.split(".")
																	lowercase__:    Tuple        =      detectrona_config
																	for attribute in attributes[:-1]:
																								lowercase__:    Optional[int]        =      getattr(UpperCAmelCase_			,				UpperCAmelCase_)
																	setattr(UpperCAmelCase_			,				attributes[-1]			,				UpperCAmelCase_)

										return detectrona_config














"""simple docstring"""





UpperCamelCase			=      {
    """0""": 1,
    """1""": 1,
    """2""": 2,
    """3""": 6,
    """4""": 24,
    """5""": 1_20,
    """6""": 7_20,
    """7""": 50_40,
    """8""": 4_03_20,
    """9""": 36_28_80,
}

UpperCamelCase			=      {1_45: 1_45}

UpperCamelCase			=      {
    1_45: 0,
    1_69: 3,
    3_63_01: 3,
    14_54: 3,
    8_71: 2,
    4_53_61: 2,
    8_72: 2,
}






def     A(  snake_case_		):
       """simple docstring"""





       if n in CACHE_SUM_DIGIT_FACTORIALS:
              return CACHE_SUM_DIGIT_FACTORIALS[n]
       lowercase__:    Any        =      sum(DIGIT_FACTORIALS[let] for let in str(snake_case_		)		)
       lowercase__:    Optional[Any]        =      ret
       return ret






def     A(  snake_case_						,       snake_case_ = None		):
       """simple docstring"""





       lowercase__:    Optional[int]        =      previous or set()
       if n in CHAIN_LENGTH_CACHE:
              return CHAIN_LENGTH_CACHE[n]
       lowercase__:    Tuple        =      sum_digit_factorials(snake_case_		)
       if next_number in previous:
              lowercase__:    List[Any]        =      0
              return 0
       else:
              previous.add(snake_case_		)
              lowercase__:    Optional[int]        =      1 + chain_length(snake_case_						,       snake_case_		)
              lowercase__:    Any        =      ret
              return ret






def     A(  snake_case_ = 60						,       snake_case_ = 1000000		):
       """simple docstring"""





       return sum(1 for i in range(1						,       snake_case_		) if chain_length(snake_case_		) == num_terms		)


if __name__ == "__main__":
  print(F"{solution() = }")






