


'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast
from ...utils import logging


_UpperCAmelCase					:			Dict				     =					logging.get_logger(__name__)

_UpperCAmelCase					:			Dict				     =					{
    """uclanlp/plbart-base""": """https://huggingface.co/uclanlp/plbart-base/resolve/main/config.json""",
    # See all PLBART models at https://huggingface.co/models?filter=plbart
}


class    a__					(			__A   ):







				"""simple docstring"""



				__UpperCamelCase     :		Any						=						'plbart'
				__UpperCamelCase     :		Optional[Any]						=						['past_key_values']
				__UpperCamelCase     :		int						=						{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}




				def __init__(self							,      __lowercase=5_00_05							,      __lowercase=10_24							,      __lowercase=6							,      __lowercase=30_72							,      __lowercase=12							,      __lowercase=6							,      __lowercase=30_72							,      __lowercase=12							,      __lowercase=0.0							,      __lowercase=0.0							,      __lowercase=True							,      __lowercase=True							,      __lowercase="gelu"							,      __lowercase=7_68							,      __lowercase=0.1							,      __lowercase=0.1							,      __lowercase=0.0							,      __lowercase=0.0_2							,      __lowercase=0.0							,      __lowercase=True							,      __lowercase=1							,      __lowercase=0							,      __lowercase=2							,      __lowercase=2							,      **__lowercase							,      ):
										__lowerCAmelCase											=					vocab_size
										__lowerCAmelCase											=					max_position_embeddings
										__lowerCAmelCase											=					d_model
										__lowerCAmelCase											=					encoder_ffn_dim
										__lowerCAmelCase											=					encoder_layers
										__lowerCAmelCase											=					encoder_attention_heads
										__lowerCAmelCase											=					decoder_ffn_dim
										__lowerCAmelCase											=					decoder_layers
										__lowerCAmelCase											=					decoder_attention_heads
										__lowerCAmelCase											=					dropout
										__lowerCAmelCase											=					attention_dropout
										__lowerCAmelCase											=					activation_dropout
										__lowerCAmelCase											=					activation_function
										__lowerCAmelCase											=					init_std
										__lowerCAmelCase											=					encoder_layerdrop
										__lowerCAmelCase											=					decoder_layerdrop
										__lowerCAmelCase											=					classifier_dropout
										__lowerCAmelCase											=					use_cache
										__lowerCAmelCase											=					encoder_layers
										__lowerCAmelCase											=					scale_embedding  # scale factor will be sqrt(d_model) if True
										super().__init__(
										    pad_token_id=__lowercase							,      bos_token_id=__lowercase							,      eos_token_id=__lowercase							,      is_encoder_decoder=__lowercase							,      forced_eos_token_id=__lowercase							,      **__lowercase							,      )


class    a__					(			__A   ):







				"""simple docstring"""



				@property
				def        _snake_case	(self		):
										return OrderedDict(
										    [
										        ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
										        ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
										    ]		)




				@property
				def        _snake_case	(self		):
										if self.use_past:
																return OrderedDict(
																    [
																        ('''last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																        ('''past_keys''', {0: '''batch''', 2: '''sequence'''}),
																        ('''encoder_last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																    ]		)
										else:
																return OrderedDict(
																    [
																        ('''last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																        ('''encoder_last_hidden_state''', {0: '''batch''', 1: '''sequence'''}),
																    ]		)





'''simple docstring'''

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


_UpperCAmelCase					:			Optional[int]				     =					logging.get_logger(__name__)

_UpperCAmelCase					:			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__					(			__A   ):







				"""simple docstring"""



				__UpperCamelCase     :		List[Any]						=						'layoutlmv2'




				def __init__(self							,      __lowercase=3_05_22							,      __lowercase=7_68							,      __lowercase=12							,      __lowercase=12							,      __lowercase=30_72							,      __lowercase="gelu"							,      __lowercase=0.1							,      __lowercase=0.1							,      __lowercase=5_12							,      __lowercase=2							,      __lowercase=0.0_2							,      __lowercase=1e-12							,      __lowercase=0							,      __lowercase=10_24							,      __lowercase=1_28							,      __lowercase=32							,      __lowercase=True							,      __lowercase=2_56							,      __lowercase=64							,      __lowercase=True							,      __lowercase=[7, 7, 2_56]							,      __lowercase=1_28							,      __lowercase=1_28							,      __lowercase=True							,      __lowercase=True							,      __lowercase=False							,      __lowercase=None							,      **__lowercase							,      ):
										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							,      )
										__lowerCAmelCase											=					max_ad_position_embeddings
										__lowerCAmelCase											=					max_rel_pos
										__lowerCAmelCase											=					rel_pos_bins
										__lowerCAmelCase											=					fast_qkv
										__lowerCAmelCase											=					max_rel_ad_pos
										__lowerCAmelCase											=					rel_ad_pos_bins
										__lowerCAmelCase											=					convert_sync_batchnorm
										__lowerCAmelCase											=					image_feature_pool_shape
										__lowerCAmelCase											=					coordinate_size
										__lowerCAmelCase											=					shape_size
										__lowerCAmelCase											=					has_relative_attention_bias
										__lowerCAmelCase											=					has_spatial_attention_bias
										__lowerCAmelCase											=					has_visual_segment_embedding
										__lowerCAmelCase											=					(
										    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
										)




				@classmethod
				def        _snake_case	(self		):
										return {
										    "MODEL.MASK_ON": True,
										    "MODEL.PIXEL_STD": [5_7.3_7_5, 5_7.1_2_0, 5_8.3_9_5],
										    "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        _snake_case	(self		):
										__lowerCAmelCase											=					detectrona.config.get_cfg()
										for k, v in self.detectrona_config_args.items():
																__lowerCAmelCase											=					k.split('''.'''		)
																__lowerCAmelCase											=					detectrona_config
																for attribute in attributes[:-1]:
																						__lowerCAmelCase											=					getattr(__lowercase							,      __lowercase		)
																setattr(__lowercase							,      attributes[-1]							,      __lowercase		)

										return detectrona_config

