


"""simple docstring"""




class       _lowercase			:


       """simple docstring"""




       class       _lowercase			:


              """simple docstring"""




              A__ 						=      "_prev", "_data", "_next"





              def __init__(       self							:      int ,				__lowerCamelCase							:      Optional[Any] ,				__lowerCamelCase							:      List[Any] ,				__lowerCamelCase							:      Tuple	):


                    '''simple docstring'''



                    lowerCamelCase__		:    Union[str, Any]   =  link_p
                    lowerCamelCase__		:    Union[str, Any]   =  element
                    lowerCamelCase__		:    Union[str, Any]   =  link_n





              def 						lowerCAmelCase					(       self							:      Any	):


                    '''simple docstring'''



                    return (
                        f" Prev -> {self._prev is not None}, Next -> {self._next is not None}"
                    )





       def __init__(       self							:      Any	):


             '''simple docstring'''



             lowerCamelCase__		:    List[Any]   =  self._Node(__lowerCamelCase ,				__lowerCamelCase ,				__lowerCamelCase	)
             lowerCamelCase__		:    List[str]   =  self._Node(__lowerCamelCase ,				__lowerCamelCase ,				__lowerCamelCase	)
             lowerCamelCase__		:    Dict   =  self._trailer
             lowerCamelCase__		:    List[Any]   =  self._header
             lowerCamelCase__		:    Union[str, Any]   =  0





       def __len__(       self							:      List[Any]	):


             '''simple docstring'''



             return self._size





       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             return self.__len__() == 0





       def 						lowerCAmelCase					(       self							:      Optional[int] ,				__lowerCamelCase							:      Optional[int] ,				__lowerCamelCase							:      Tuple ,				__lowerCamelCase							:      Union[str, Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Dict   =  self._Node(__lowerCamelCase ,				__lowerCamelCase ,				__lowerCamelCase	)
             lowerCamelCase__		:    Tuple   =  new_node
             lowerCamelCase__		:    Optional[int]   =  new_node
             self._size += 1
             return self





       def 						lowerCAmelCase					(       self							:      Any ,				__lowerCamelCase							:      Union[str, Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Dict   =  node._prev
             lowerCamelCase__		:    int   =  node._next

             lowerCamelCase__		:    int   =  successor
             lowerCamelCase__		:    Dict   =  predecessor
             self._size -= 1
             lowerCamelCase__		:    Optional[int]   =  node._data
             lowerCamelCase__		:    int   =  None
             del node
             return temp







class       _lowercase			(							_DoublyLinkedBase):


       """simple docstring"""




       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             if self.is_empty():
                   raise Exception("List is empty"	)
             return self._header._next._data





       def 						lowerCAmelCase					(       self							:      Any	):


             '''simple docstring'''



             if self.is_empty():
                   raise Exception("List is empty"	)
             return self._trailer._prev._data





       def 						lowerCAmelCase					(       self							:      List[str] ,				__lowerCamelCase							:      List[Any]	):


             '''simple docstring'''



             return self._insert(self._header ,				__lowerCamelCase ,				self._header._next	)





       def 						lowerCAmelCase					(       self							:      Optional[Any] ,				__lowerCamelCase							:      List[Any]	):


             '''simple docstring'''



             return self._insert(self._trailer._prev ,				__lowerCamelCase ,				self._trailer	)





       def 						lowerCAmelCase					(       self							:      Union[str, Any]	):


             '''simple docstring'''



             if self.is_empty():
                   raise IndexError("remove_first from empty list"	)
             return self._delete(self._header._next	)





       def 						lowerCAmelCase					(       self							:      Optional[Any]	):


             '''simple docstring'''



             if self.is_empty():
                   raise IndexError("remove_first from empty list"	)
             return self._delete(self._trailer._prev	)






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


A				:   int		= logging.get_logger(__name__)

A				:   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       _lowercase			(							lowercase__):


       """simple docstring"""




       A__ 						=      "layoutlmv2"





       def __init__(       self							:      Union[str, Any] ,				__lowerCamelCase							:      int=30522 ,				__lowerCamelCase							:      List[Any]=768 ,				__lowerCamelCase							:      Any=12 ,				__lowerCamelCase							:      List[Any]=12 ,				__lowerCamelCase							:      Optional[Any]=3072 ,				__lowerCamelCase							:      List[Any]="gelu" ,				__lowerCamelCase							:      Any=0.1 ,				__lowerCamelCase							:      Union[str, Any]=0.1 ,				__lowerCamelCase							:      int=512 ,				__lowerCamelCase							:      str=2 ,				__lowerCamelCase							:      Any=0.0_2 ,				__lowerCamelCase							:      List[Any]=1E-1_2 ,				__lowerCamelCase							:      List[str]=0 ,				__lowerCamelCase							:      Union[str, Any]=1024 ,				__lowerCamelCase							:      Tuple=128 ,				__lowerCamelCase							:      Tuple=32 ,				__lowerCamelCase							:      Union[str, Any]=True ,				__lowerCamelCase							:      List[Any]=256 ,				__lowerCamelCase							:      Dict=64 ,				__lowerCamelCase							:      List[Any]=True ,				__lowerCamelCase							:      Union[str, Any]=[7, 7, 256] ,				__lowerCamelCase							:      str=128 ,				__lowerCamelCase							:      Dict=128 ,				__lowerCamelCase							:      Dict=True ,				__lowerCamelCase							:      int=True ,				__lowerCamelCase							:      str=False ,				__lowerCamelCase							:      Tuple=None ,				**__lowerCamelCase							:      str ,				):


             '''simple docstring'''



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





       @classmethod
       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''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": [[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 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



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

             return detectrona_config


