"""simple docstring"""






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


UpperCamelCase     					=     logging.get_logger(__name__)

UpperCamelCase     					=     {
    '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   UpperCAmelCase__				(    __lowerCamelCase			):


	"""simple docstring"""
	lowerCAmelCase__    :					List[str]						      =							"""layoutlmv2"""







	def __init__(			self       ,     _SCREAMING_SNAKE_CASE=3_0_5_2_2       ,     _SCREAMING_SNAKE_CASE=7_6_8       ,     _SCREAMING_SNAKE_CASE=1_2       ,     _SCREAMING_SNAKE_CASE=1_2       ,     _SCREAMING_SNAKE_CASE=3_0_7_2       ,     _SCREAMING_SNAKE_CASE="gelu"       ,     _SCREAMING_SNAKE_CASE=0.1       ,     _SCREAMING_SNAKE_CASE=0.1       ,     _SCREAMING_SNAKE_CASE=5_1_2       ,     _SCREAMING_SNAKE_CASE=2       ,     _SCREAMING_SNAKE_CASE=0.0_2       ,     _SCREAMING_SNAKE_CASE=1E-12       ,     _SCREAMING_SNAKE_CASE=0       ,     _SCREAMING_SNAKE_CASE=1_0_2_4       ,     _SCREAMING_SNAKE_CASE=1_2_8       ,     _SCREAMING_SNAKE_CASE=3_2       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=2_5_6       ,     _SCREAMING_SNAKE_CASE=6_4       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=[7, 7, 2_5_6]       ,     _SCREAMING_SNAKE_CASE=1_2_8       ,     _SCREAMING_SNAKE_CASE=1_2_8       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=False       ,     _SCREAMING_SNAKE_CASE=None       ,     **_SCREAMING_SNAKE_CASE       ,     )    ->	Optional[Any]:
							super().__init__(
							    vocab_size=_SCREAMING_SNAKE_CASE       ,     hidden_size=_SCREAMING_SNAKE_CASE       ,     num_hidden_layers=_SCREAMING_SNAKE_CASE       ,     num_attention_heads=_SCREAMING_SNAKE_CASE       ,     intermediate_size=_SCREAMING_SNAKE_CASE       ,     hidden_act=_SCREAMING_SNAKE_CASE       ,     hidden_dropout_prob=_SCREAMING_SNAKE_CASE       ,     attention_probs_dropout_prob=_SCREAMING_SNAKE_CASE       ,     max_position_embeddings=_SCREAMING_SNAKE_CASE       ,     type_vocab_size=_SCREAMING_SNAKE_CASE       ,     initializer_range=_SCREAMING_SNAKE_CASE       ,     layer_norm_eps=_SCREAMING_SNAKE_CASE       ,     pad_token_id=_SCREAMING_SNAKE_CASE       ,     **_SCREAMING_SNAKE_CASE       ,     )
							a_							:			Dict     		=					max_ad_position_embeddings
							a_							:			str     		=					max_rel_pos
							a_							:			int     		=					rel_pos_bins
							a_							:			Optional[int]     		=					fast_qkv
							a_							:			Optional[Any]     		=					max_rel_ad_pos
							a_							:			int     		=					rel_ad_pos_bins
							a_							:			Any     		=					convert_sync_batchnorm
							a_							:			Dict     		=					image_feature_pool_shape
							a_							:			Union[str, Any]     		=					coordinate_size
							a_							:			Dict     		=					shape_size
							a_							:			List[str]     		=					has_relative_attention_bias
							a_							:			Tuple     		=					has_spatial_attention_bias
							a_							:			str     		=					has_visual_segment_embedding
							a_							:			Any     		=					(
							    detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
							)







	@classmethod
	def       A    (			self )    ->	List[Any]:
							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": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
							    "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
							    "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 2_0_0_0,
							    "MODEL.RPN.PRE_NMS_TOPK_TEST": 1_0_0_0,
							    "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1_0_0_0,
							    "MODEL.POST_NMS_TOPK_TEST": 1_0_0_0,
							    "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": 1_4,
							    "MODEL.ROI_MASK_HEAD.NAME": "MaskRCNNConvUpsampleHead",
							    "MODEL.ROI_MASK_HEAD.NUM_CONV": 4,
							    "MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION": 7,
							    "MODEL.RESNETS.DEPTH": 1_0_1,
							    "MODEL.RESNETS.SIZES": [[3_2], [6_4], [1_2_8], [2_5_6], [5_1_2]],
							    "MODEL.RESNETS.ASPECT_RATIOS": [[0.5, 1.0, 2.0]],
							    "MODEL.RESNETS.OUT_FEATURES": ["res2", "res3", "res4", "res5"],
							    "MODEL.RESNETS.NUM_GROUPS": 3_2,
							    "MODEL.RESNETS.WIDTH_PER_GROUP": 8,
							    "MODEL.RESNETS.STRIDE_IN_1X1": False,
							}







	def       A    (			self )    ->	Optional[int]:
							a_							:			str     		=					detectrona.config.get_cfg()
							for k, v in self.detectrona_config_args.items():
													a_							:			str     		=					k.split("." )
													a_							:			Optional[int]     		=					detectrona_config
													for attribute in attributes[:-1]:
																			a_							:			Any     		=					getattr(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE )
													setattr(_SCREAMING_SNAKE_CASE       ,     attributes[-1]       ,     _SCREAMING_SNAKE_CASE )

							return detectrona_config





"""simple docstring"""






import unittest

import torch

from diffusers import DDIMScheduler, TextToVideoZeroPipeline
from diffusers.utils import load_pt, require_torch_gpu, slow

from ..test_pipelines_common import assert_mean_pixel_difference
@slow
@require_torch_gpu
class   UpperCAmelCase__				(    unittest.TestCase			):


	"""simple docstring"""







	def       A    (			self )    ->	List[str]:
							a_							:			List[str]     		=					"runwayml/stable-diffusion-v1-5"
							a_							:			Optional[int]     		=					TextToVideoZeroPipeline.from_pretrained(_SCREAMING_SNAKE_CASE       ,     torch_dtype=torch.floataa ).to("cuda" )
							a_							:			Dict     		=					DDIMScheduler.from_config(pipe.scheduler.config )
							a_							:			Optional[Any]     		=					torch.Generator(device="cuda" ).manual_seed(0 )

							a_							:			List[Any]     		=					"A bear is playing a guitar on Times Square"
							a_							:			List[Any]     		=					pipe(prompt=_SCREAMING_SNAKE_CASE       ,     generator=_SCREAMING_SNAKE_CASE ).images

							a_							:			Optional[int]     		=					load_pt(
							    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/A bear is playing a guitar on Times Square.pt" )

							assert_mean_pixel_difference(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE )




