


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


__UpperCamelCase							:							Tuple    							=					logging.get_logger(__name__)

__UpperCamelCase							:							List[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    __magic_name__						(  __lowerCAmelCase):
     A:		List[Any]								=   "layoutlmv2"


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





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


     @classmethod
     def   UpperCAmelCase__						(   self				:  Any      )	->   Any:





      '''simple docstring'''






      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   UpperCAmelCase__						(   self				:  Any      )	->   Tuple:





      '''simple docstring'''






      UpperCamelCase__       :     Union[str, Any] 							= detectrona.config.get_cfg()
      for k, v in self.detectrona_config_args.items():
       UpperCamelCase__       :     List[str] 							= k.split('''.'''      )
       UpperCamelCase__       :     Tuple 							= detectrona_config
       for attribute in attributes[:-1]:
        UpperCamelCase__       :     str 							= getattr(lowerCamelCase__				,						lowerCamelCase__      )
       setattr(lowerCamelCase__				,						attributes[-1]				,						lowerCamelCase__      )

      return detectrona_config






from hashlib import mda, shaaaa

__UpperCamelCase							:							Dict    							=					(shaaaa, mda)

class    __magic_name__						:


     def __init__(   self				:  Optional[Any]				,						lowerCamelCase__				:  int = 8      )	->   None:





      '''simple docstring'''






      UpperCamelCase__       :     int 							= 0b0
      UpperCamelCase__       :     Optional[int] 							= size


     def   UpperCAmelCase__						(   self				:  Tuple				,						lowerCamelCase__				:  str      )	->   None:





      '''simple docstring'''






      UpperCamelCase__       :     Union[str, Any] 							= self.hash_(lowerCamelCase__      )
      self.bitarray |= h


     def   UpperCAmelCase__						(   self				:  Any				,						lowerCamelCase__				:  str      )	->   bool:





      '''simple docstring'''






      UpperCamelCase__       :     Any 							= self.hash_(lowerCamelCase__      )
      return (h & self.bitarray) == h


     def __contains__(   self				:  Any				,						lowerCamelCase__				:  str      )	->   bool:





      '''simple docstring'''






      return self.exists(lowerCamelCase__      )


     def   UpperCAmelCase__						(   self				:  Union[str, Any]				,						lowerCamelCase__				:  int      )	->   str:





      '''simple docstring'''






      UpperCamelCase__       :     Optional[int] 							= bin(lowerCamelCase__      )[2:]
      return res.zfill(self.size      )


     @property
     def   UpperCAmelCase__						(   self				:  Tuple      )	->   str:





      '''simple docstring'''






      return self.format_bin(self.bitarray      )


     def   UpperCAmelCase__						(   self				:  int				,						lowerCamelCase__				:  str      )	->   int:





      '''simple docstring'''






      UpperCamelCase__       :     Union[str, Any] 							= 0b0
      for func in HASH_FUNCTIONS:
       UpperCamelCase__       :     Optional[Any] 							= (
           int.from_bytes(func(value.encode()      ).digest()				,						'''little'''      ) % self.size
       )
       res |= 2**position
      return res


     def   UpperCAmelCase__						(   self				:  Union[str, Any]				,						lowerCamelCase__				:  str      )	->   str:





      '''simple docstring'''






      return self.format_bin(self.hash_(lowerCamelCase__      )      )


     @property
     def   UpperCAmelCase__						(   self				:  str      )	->   float:





      '''simple docstring'''






      UpperCamelCase__       :     Tuple 							= bin(self.bitarray      ).count('''1'''      )
      return (n_ones / self.size) ** len(lowerCamelCase__      )


