

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


__A     						=      logging.get_logger(__name__)

__A     						=      {
    '''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	):
      UpperCamelCase_     :						Optional[Any]		 =							"layoutlmv2"



      def __init__(     self :							int     ,   A__ :							Tuple=30522     ,   A__ :							Dict=768     ,   A__ :							Optional[Any]=12     ,   A__ :							List[Any]=12     ,   A__ :							List[str]=3072     ,   A__ :							int="gelu"     ,   A__ :							int=0.1     ,   A__ :							int=0.1     ,   A__ :							Any=512     ,   A__ :							Optional[int]=2     ,   A__ :							Tuple=0.02     ,   A__ :							Optional[Any]=1e-12     ,   A__ :							str=0     ,   A__ :							int=1024     ,   A__ :							Dict=128     ,   A__ :							List[Any]=32     ,   A__ :							Optional[int]=True     ,   A__ :							Tuple=256     ,   A__ :							List[Any]=64     ,   A__ :							List[Any]=True     ,   A__ :							Union[str, Any]=[7, 7, 256]     ,   A__ :							Optional[int]=128     ,   A__ :							int=128     ,   A__ :							Optional[Any]=True     ,   A__ :							Optional[int]=True     ,   A__ :							Dict=False     ,   A__ :							Any=None     ,   **A__ :							Dict     ,   )       ->	Union[str, Any]:
        super().__init__(
            vocab_size=A__     ,   hidden_size=A__     ,   num_hidden_layers=A__     ,   num_attention_heads=A__     ,   intermediate_size=A__     ,   hidden_act=A__     ,   hidden_dropout_prob=A__     ,   attention_probs_dropout_prob=A__     ,   max_position_embeddings=A__     ,   type_vocab_size=A__     ,   initializer_range=A__     ,   layer_norm_eps=A__     ,   pad_token_id=A__     ,   **A__     ,   )
        _snake_case		=				max_ad_position_embeddings
        _snake_case		=				max_rel_pos
        _snake_case		=				rel_pos_bins
        _snake_case		=				fast_qkv
        _snake_case		=				max_rel_ad_pos
        _snake_case		=				rel_ad_pos_bins
        _snake_case		=				convert_sync_batchnorm
        _snake_case		=				image_feature_pool_shape
        _snake_case		=				coordinate_size
        _snake_case		=				shape_size
        _snake_case		=				has_relative_attention_bias
        _snake_case		=				has_spatial_attention_bias
        _snake_case		=				has_visual_segment_embedding
        _snake_case		=				(
            detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
        )



      @classmethod
      def 		UpperCamelCase_						(     self :							Optional[Any]						)       ->	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 		UpperCamelCase_						(     self :							List[str]						)       ->	Union[str, Any]:
        _snake_case		=				detectrona.config.get_cfg()
        for k, v in self.detectrona_config_args.items():
          _snake_case		=				k.split('''.'''						)
          _snake_case		=				detectrona_config
          for attribute in attributes[:-1]:
            _snake_case		=				getattr(A__     ,   A__						)
          setattr(A__     ,   attributes[-1]     ,   A__						)

        return detectrona_config




from __future__ import annotations

from collections import Counter



def  snake_case_(_UpperCamelCase	)				->      list[int]:



  """simple docstring"""






  _snake_case		=				[True] * n
  _snake_case		=				False
  _snake_case		=				False
  _snake_case		=				True

  for i in range(3					,			int(n**0.5 + 1	)					,			2	):
    _snake_case		=				i * 2
    while index < n:
      _snake_case		=				False
      _snake_case		=				index + i

  _snake_case		=				[2]

  for i in range(3					,			_UpperCamelCase					,			2	):
    if is_prime[i]:
      primes.append(_UpperCamelCase	)

  return primes



def  snake_case_(_UpperCamelCase	)				->      list[list[int]]:



  """simple docstring"""






  _snake_case		=				str(_UpperCamelCase	)
  _snake_case		=				[]
  _snake_case		=				['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

  for duplicate in Counter(_UpperCamelCase	) - Counter(set(_UpperCamelCase	)	):
    _snake_case		=				[int(number_str.replace(_UpperCamelCase					,			_UpperCamelCase	)	) for digit in digits]
    replacements.append(_UpperCamelCase	)

  return replacements



def  snake_case_(_UpperCamelCase = 8	)				->      int:



  """simple docstring"""






  _snake_case		=				set()

  # Filter primes with less than 3 replaceable digits
  _snake_case		=				{
      x for x in set(prime_sieve(1_000_000	)	) if len(str(_UpperCamelCase	)	) - len(set(str(_UpperCamelCase	)	)	) >= 3
  }

  for prime in primes:
    if prime in numbers_checked:
      continue

    _snake_case		=				digit_replacements(_UpperCamelCase	)

    for family in replacements:
      numbers_checked.update(_UpperCamelCase	)
      _snake_case		=				primes.intersection(_UpperCamelCase	)

      if len(_UpperCamelCase	) != family_length:
        continue

      return min(_UpperCamelCase	)

  return -1


if __name__ == "__main__":
 print(solution())

