
"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import is_detectrona_available, logging


SCREAMING_SNAKE_CASE_			      =					logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_			      =					{
    '''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      lowerCAmelCase_						(							A__				):



							'''simple docstring'''





							_snake_case		     =						'''layoutlmv2'''




							def __init__(				self  ,							snake_case_=30_522  ,							snake_case_=768  ,							snake_case_=12  ,							snake_case_=12  ,							snake_case_=3_072  ,							snake_case_="gelu"  ,							snake_case_=0.1  ,							snake_case_=0.1  ,							snake_case_=512  ,							snake_case_=2  ,							snake_case_=0.02  ,							snake_case_=1e-1_2  ,							snake_case_=0  ,							snake_case_=1_024  ,							snake_case_=128  ,							snake_case_=32  ,							snake_case_=True  ,							snake_case_=256  ,							snake_case_=64  ,							snake_case_=True  ,							snake_case_=[7, 7, 256]  ,							snake_case_=128  ,							snake_case_=128  ,							snake_case_=True  ,							snake_case_=True  ,							snake_case_=False  ,							snake_case_=None  ,							**snake_case_  ,							)   ->       List[str]:
													super().__init__(
													    vocab_size=snake_case_  ,							hidden_size=snake_case_  ,							num_hidden_layers=snake_case_  ,							num_attention_heads=snake_case_  ,							intermediate_size=snake_case_  ,							hidden_act=snake_case_  ,							hidden_dropout_prob=snake_case_  ,							attention_probs_dropout_prob=snake_case_  ,							max_position_embeddings=snake_case_  ,							type_vocab_size=snake_case_  ,							initializer_range=snake_case_  ,							layer_norm_eps=snake_case_  ,							pad_token_id=snake_case_  ,							**snake_case_  ,							)
													__lowerCAmelCase        =       max_ad_position_embeddings
													__lowerCAmelCase        =       max_rel_pos
													__lowerCAmelCase        =       rel_pos_bins
													__lowerCAmelCase        =       fast_qkv
													__lowerCAmelCase        =       max_rel_ad_pos
													__lowerCAmelCase        =       rel_ad_pos_bins
													__lowerCAmelCase        =       convert_sync_batchnorm
													__lowerCAmelCase        =       image_feature_pool_shape
													__lowerCAmelCase        =       coordinate_size
													__lowerCAmelCase        =       shape_size
													__lowerCAmelCase        =       has_relative_attention_bias
													__lowerCAmelCase        =       has_spatial_attention_bias
													__lowerCAmelCase        =       has_visual_segment_embedding
													__lowerCAmelCase        =       (
													    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
													)




							@classmethod
							def  A__		(				self							)   ->       Any:
													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": 2_000,
													    "MODEL.RPN.PRE_NMS_TOPK_TEST": 1_000,
													    "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1_000,
													    "MODEL.POST_NMS_TOPK_TEST": 1_000,
													    "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  A__		(				self							)   ->       str:
													__lowerCAmelCase        =       detectrona.config.get_cfg()
													for k, v in self.detectrona_config_args.items():
																			__lowerCAmelCase        =       k.split("""."""							)
																			__lowerCAmelCase        =       detectrona_config
																			for attribute in attributes[:-1]:
																									__lowerCAmelCase        =       getattr(snake_case_  ,							snake_case_							)
																			setattr(snake_case_  ,							attributes[-1]  ,							snake_case_							)

													return detectrona_config


"""simple docstring"""
import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
			import torch
class      lowerCAmelCase_						(							unittest.TestCase							,							A__				):



							'''simple docstring'''





							def  A__		(				self							)   ->       Any:
													__lowerCAmelCase        =       load_tool("""speech-to-text"""							)
													self.tool.setup()




							def  A__		(				self							)   ->       int:
													__lowerCAmelCase        =       self.tool(torch.ones(3_000							)							)
													self.assertEqual(snake_case_  ,							""" you"""							)




							def  A__		(				self							)   ->       Optional[int]:
													__lowerCAmelCase        =       self.tool(audio=torch.ones(3_000							)							)
													self.assertEqual(snake_case_  ,							""" you"""							)
