






'''simple docstring'''


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


lowerCamelCase_					:			Any     						=				logging.get_logger(__name__)

lowerCamelCase_					:			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  _SCREAMING_SNAKE_CASE				(		SCREAMING_SNAKE_CASE						):


			'''simple docstring'''





			__a				:				Optional[int]         =       "layoutlmv2"






			def __init__( self				:    Any			,   lowercase				:    Tuple=3_0_5_2_2			,   lowercase				:    Optional[Any]=7_6_8			,   lowercase				:    Optional[Any]=1_2			,   lowercase				:    List[str]=1_2			,   lowercase				:    List[Any]=3_0_7_2			,   lowercase				:    Dict="gelu"			,   lowercase				:    Union[str, Any]=0.1			,   lowercase				:    Tuple=0.1			,   lowercase				:    Optional[int]=5_1_2			,   lowercase				:    Any=2			,   lowercase				:    str=0.0_2			,   lowercase				:    Optional[int]=1e-12			,   lowercase				:    str=0			,   lowercase				:    List[str]=1_0_2_4			,   lowercase				:    List[Any]=1_2_8			,   lowercase				:    int=3_2			,   lowercase				:    Tuple=True			,   lowercase				:    Union[str, Any]=2_5_6			,   lowercase				:    List[str]=6_4			,   lowercase				:    Union[str, Any]=True			,   lowercase				:    str=[7, 7, 2_5_6]			,   lowercase				:    str=1_2_8			,   lowercase				:    Tuple=1_2_8			,   lowercase				:    Dict=True			,   lowercase				:    Optional[Any]=True			,   lowercase				:    int=False			,   lowercase				:    Dict=None			,   **lowercase				:    int			,   )				->     Dict:

									'''simple docstring'''







									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			,   )
									UpperCamelCase__       =			max_ad_position_embeddings
									UpperCamelCase__       =			max_rel_pos
									UpperCamelCase__       =			rel_pos_bins
									UpperCamelCase__       =			fast_qkv
									UpperCamelCase__       =			max_rel_ad_pos
									UpperCamelCase__       =			rel_ad_pos_bins
									UpperCamelCase__       =			convert_sync_batchnorm
									UpperCamelCase__       =			image_feature_pool_shape
									UpperCamelCase__       =			coordinate_size
									UpperCamelCase__       =			shape_size
									UpperCamelCase__       =			has_relative_attention_bias
									UpperCamelCase__       =			has_spatial_attention_bias
									UpperCamelCase__       =			has_visual_segment_embedding
									UpperCamelCase__       =			(
									    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
									)






			@classmethod
			def 					A   ( self				:    Dict      )				->     Tuple:

									'''simple docstring'''







									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": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
									    "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
									    "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 2_0_0_0,
									    "MODEL.RPN.PRE_NMS_TOPK_TEST": 1_0_0_0,
									    "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1_0_0_0,
									    "MODEL.POST_NMS_TOPK_TEST": 1_0_0_0,
									    "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": 1_4,
									    "MODEL.ROI_MASK_HEAD.NAME": "MaskRCNNConvUpsampleHead",
									    "MODEL.ROI_MASK_HEAD.NUM_CONV": 4,
									    "MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION": 7,
									    "MODEL.RESNETS.DEPTH": 1_0_1,
									    "MODEL.RESNETS.SIZES": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
									    "MODEL.RESNETS.ASPECT_RATIOS": [[0.5, 1.0, 2.0]],
									    "MODEL.RESNETS.OUT_FEATURES": ["res2", "res3", "res4", "res5"],
									    "MODEL.RESNETS.NUM_GROUPS": 3_2,
									    "MODEL.RESNETS.WIDTH_PER_GROUP": 8,
									    "MODEL.RESNETS.STRIDE_IN_1X1": False,
									}







			def 					A   ( self				:    List[str]      )				->     Optional[int]:

									'''simple docstring'''







									UpperCamelCase__       =			detectrona.config.get_cfg()
									for k, v in self.detectrona_config_args.items():
															UpperCamelCase__       =			k.split("""."""      )
															UpperCamelCase__       =			detectrona_config
															for attribute in attributes[:-1]:
																					UpperCamelCase__       =			getattr(lowercase			,   lowercase      )
															setattr(lowercase			,   attributes[-1]			,   lowercase      )

									return detectrona_config








'''simple docstring'''


from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available
@dataclass
# Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
class  _SCREAMING_SNAKE_CASE				(		SCREAMING_SNAKE_CASE						):


			'''simple docstring'''





			__a				:				Union[List[PIL.Image.Image], np.ndarray]
			__a				:				Optional[List[bool]]


if is_transformers_available() and is_torch_available():
					from .modeling_roberta_series import RobertaSeriesModelWithTransformation
					from .pipeline_alt_diffusion import AltDiffusionPipeline
					from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline
