





'''simple docstring'''


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


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

_lowerCamelCase					:						Optional[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 				__UpperCAmelCase	(							A__    ):







		'''simple docstring'''







		__lowerCAmelCase								=     '''layoutlmv2'''







		def __init__(self    :   Tuple   ,   _lowerCAmelCase    :   Optional[int]=3_0522   ,   _lowerCAmelCase    :   Tuple=768   ,   _lowerCAmelCase    :   List[str]=12   ,   _lowerCAmelCase    :   List[str]=12   ,   _lowerCAmelCase    :   Tuple=3072   ,   _lowerCAmelCase    :   int="gelu"   ,   _lowerCAmelCase    :   Any=0.1   ,   _lowerCAmelCase    :   Dict=0.1   ,   _lowerCAmelCase    :   Any=512   ,   _lowerCAmelCase    :   Optional[int]=2   ,   _lowerCAmelCase    :   List[Any]=0.02   ,   _lowerCAmelCase    :   Any=1e-12   ,   _lowerCAmelCase    :   List[str]=0   ,   _lowerCAmelCase    :   Optional[int]=1024   ,   _lowerCAmelCase    :   Optional[Any]=128   ,   _lowerCAmelCase    :   Dict=32   ,   _lowerCAmelCase    :   Any=True   ,   _lowerCAmelCase    :   Optional[int]=256   ,   _lowerCAmelCase    :   Optional[int]=64   ,   _lowerCAmelCase    :   List[Any]=True   ,   _lowerCAmelCase    :   Union[str, Any]=[7, 7, 256]   ,   _lowerCAmelCase    :   Optional[int]=128   ,   _lowerCAmelCase    :   Tuple=128   ,   _lowerCAmelCase    :   int=True   ,   _lowerCAmelCase    :   Union[str, Any]=True   ,   _lowerCAmelCase    :   Optional[int]=False   ,   _lowerCAmelCase    :   Optional[int]=None   ,   **_lowerCAmelCase    :   Optional[int]   ,   ):
			super().__init__(
			    vocab_size=_lowerCAmelCase   ,   hidden_size=_lowerCAmelCase   ,   num_hidden_layers=_lowerCAmelCase   ,   num_attention_heads=_lowerCAmelCase   ,   intermediate_size=_lowerCAmelCase   ,   hidden_act=_lowerCAmelCase   ,   hidden_dropout_prob=_lowerCAmelCase   ,   attention_probs_dropout_prob=_lowerCAmelCase   ,   max_position_embeddings=_lowerCAmelCase   ,   type_vocab_size=_lowerCAmelCase   ,   initializer_range=_lowerCAmelCase   ,   layer_norm_eps=_lowerCAmelCase   ,   pad_token_id=_lowerCAmelCase   ,   **_lowerCAmelCase   ,   )
			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 							A  (self    :   Optional[int]   ):
			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 							A  (self    :   Tuple   ):
			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(_lowerCAmelCase   ,   _lowerCAmelCase   )
				setattr(_lowerCAmelCase   ,   attributes[-1]   ,   _lowerCAmelCase   )

			return detectrona_config








'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_lowerCamelCase					:						Dict					     =							{
    'configuration_donut_swin': ['DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DonutSwinConfig'],
    'processing_donut': ['DonutProcessor'],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCamelCase					:						List[str]					     =							[
				    'DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'DonutSwinModel',
				    'DonutSwinPreTrainedModel',
				]

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCamelCase					:						Any					     =							['DonutFeatureExtractor']
				_lowerCamelCase					:						Union[str, Any]					     =							['DonutImageProcessor']


if TYPE_CHECKING:
				from .configuration_donut_swin import DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, DonutSwinConfig
				from .processing_donut import DonutProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_donut_swin import (
								    DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
								    DonutSwinModel,
								    DonutSwinPreTrainedModel,
								)

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_donut import DonutFeatureExtractor
								from .image_processing_donut import DonutImageProcessor

else:
				import sys

				_lowerCamelCase					:						Optional[int]					     =							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

