

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


lowerCamelCase									= logging.get_logger(__name__)

lowerCamelCase									= {
    '''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__							):

   '''simple docstring'''




   lowerCamelCase__			:     Union[str, Any]    =       'layoutlmv2'



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






     """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_,   )
     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 			_UpperCAmelCase			(    self	)							->   Tuple:






     """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	)							->   List[Any]:






     """simple docstring"""






     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(lowercase_,   lowercase_	)
       setattr(lowercase_,   attributes[-1],   lowercase_	)

     return detectrona_config



# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
lowerCamelCase									= abspath(join(dirname(dirname(dirname(__file__))), '''src'''))
sys.path.insert(1, git_repo_path)


# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)




def       UpperCAmelCase__    (      _A				:			List[Any]							):





  '''simple docstring'''







  from diffusers.utils.testing_utils import pytest_addoption_shared

  pytest_addoption_shared(_A							)




def       UpperCAmelCase__    (      _A				:			int							):





  '''simple docstring'''







  from diffusers.utils.testing_utils import pytest_terminal_summary_main

  a__  =terminalreporter.config.getoption('''--make-reports'''							)
  if make_reports:
    pytest_terminal_summary_main(_A     ,				id=_A							)
