
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 							A__		(     __SCREAMING_SNAKE_CASE):
      _UpperCAmelCase    :   Any   	=      """layoutlmv2"""
      def __init__(				self   ,  __magic_name__=3_0_5_2_2   ,  __magic_name__=7_6_8   ,  __magic_name__=1_2   ,  __magic_name__=1_2   ,  __magic_name__=3_0_7_2   ,  __magic_name__="gelu"   ,  __magic_name__=0.1   ,  __magic_name__=0.1   ,  __magic_name__=5_1_2   ,  __magic_name__=2   ,  __magic_name__=0.02   ,  __magic_name__=1e-12   ,  __magic_name__=0   ,  __magic_name__=1_0_2_4   ,  __magic_name__=1_2_8   ,  __magic_name__=3_2   ,  __magic_name__=True   ,  __magic_name__=2_5_6   ,  __magic_name__=6_4   ,  __magic_name__=True   ,  __magic_name__=[7, 7, 2_5_6]   ,  __magic_name__=1_2_8   ,  __magic_name__=1_2_8   ,  __magic_name__=True   ,  __magic_name__=True   ,  __magic_name__=False   ,  __magic_name__=None   ,  **__magic_name__   ,  ):
       super().__init__(
           vocab_size=__magic_name__   ,  hidden_size=__magic_name__   ,  num_hidden_layers=__magic_name__   ,  num_attention_heads=__magic_name__   ,  intermediate_size=__magic_name__   ,  hidden_act=__magic_name__   ,  hidden_dropout_prob=__magic_name__   ,  attention_probs_dropout_prob=__magic_name__   ,  max_position_embeddings=__magic_name__   ,  type_vocab_size=__magic_name__   ,  initializer_range=__magic_name__   ,  layer_norm_eps=__magic_name__   ,  pad_token_id=__magic_name__   ,  **__magic_name__   ,  )
       lowerCamelCase		:     Tuple          =				max_ad_position_embeddings
       lowerCamelCase		:     Optional[Any]          =				max_rel_pos
       lowerCamelCase		:     List[str]          =				rel_pos_bins
       lowerCamelCase		:     List[str]          =				fast_qkv
       lowerCamelCase		:     Optional[int]          =				max_rel_ad_pos
       lowerCamelCase		:     List[str]          =				rel_ad_pos_bins
       lowerCamelCase		:     List[Any]          =				convert_sync_batchnorm
       lowerCamelCase		:     Union[str, Any]          =				image_feature_pool_shape
       lowerCamelCase		:     Union[str, Any]          =				coordinate_size
       lowerCamelCase		:     Dict          =				shape_size
       lowerCamelCase		:     List[str]          =				has_relative_attention_bias
       lowerCamelCase		:     str          =				has_spatial_attention_bias
       lowerCamelCase		:     Any          =				has_visual_segment_embedding
       lowerCamelCase		:     Union[str, Any]          =				(
           detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
       )
      @classmethod
      def 						UpperCamelCase__							(				self				):
       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": [[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 						UpperCamelCase__							(				self				):
       lowerCamelCase		:     Optional[int]          =				detectrona.config.get_cfg()
       for k, v in self.detectrona_config_args.items():
        lowerCamelCase		:     str          =				k.split("""."""				)
        lowerCamelCase		:     Union[str, Any]          =				detectrona_config
        for attribute in attributes[:-1]:
         lowerCamelCase		:     List[str]          =				getattr(__magic_name__   ,  __magic_name__				)
        setattr(__magic_name__   ,  attributes[-1]   ,  __magic_name__				)

       return detectrona_config






# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
    is_vision_available,
)


_lowerCamelCase        ={
    """configuration_tvlt""": ["""TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TvltConfig"""],
    """feature_extraction_tvlt""": ["""TvltFeatureExtractor"""],
    """processing_tvlt""": ["""TvltProcessor"""],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCamelCase        =[
          """TVLT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """TvltModel""",
          """TvltForPreTraining""",
          """TvltForAudioVisualClassification""",
          """TvltPreTrainedModel""",
      ]

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCamelCase        =["""TvltImageProcessor"""]


if TYPE_CHECKING:
      from .configuration_tvlt import TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP, TvltConfig
      from .processing_tvlt import TvltProcessor
      from .feature_extraction_tvlt import TvltFeatureExtractor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tvlt import (
                TVLT_PRETRAINED_MODEL_ARCHIVE_LIST,
                TvltForAudioVisualClassification,
                TvltForPreTraining,
                TvltModel,
                TvltPreTrainedModel,
            )

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .image_processing_tvlt import TvltImageProcessor


else:
      import sys

      _lowerCamelCase        =_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




