






from importlib import import_module

from .logging import get_logger


__UpperCamelCase       :		int							=    get_logger(__name__)


class 	__SCREAMING_SNAKE_CASE:
							def __init__(  self:   Union[str, Any]							,						UpperCamelCase:   Optional[int]							,						UpperCamelCase:   Dict=None    )		->		Dict:
											snake_case__						=  attrs or []
											if module is not None:
															for key in module.__dict__:
																			if key in attrs or not key.startswith('__'    ):
																							setattr(self							,						UpperCAmelCase_							,						getattr(UpperCAmelCase_							,						UpperCAmelCase_    )    )
											snake_case__						=  module._original_module if isinstance(UpperCAmelCase_							,						_PatchedModuleObj    ) else module


class 	__SCREAMING_SNAKE_CASE:
							_UpperCAmelCase			     =							[]
							def __init__(  self:   Any							,						UpperCamelCase:   str							,						UpperCamelCase:   str							,						UpperCamelCase:   str							,						UpperCamelCase:   Dict=None    )		->		Optional[Any]:
											snake_case__						=  obj
											snake_case__						=  target
											snake_case__						=  new
											snake_case__						=  target.split('.'    )[0]
											snake_case__						=  {}
											snake_case__						=  attrs or []
							def __enter__(  self:   int    )		->		Dict:
											*snake_case__				,    snake_case__						=  self.target.split('.'    )

											# Patch modules:
											# it's used to patch attributes of submodules like "os.path.join";
											# in this case we need to patch "os" and "os.path"

											for i in range(len(UpperCAmelCase_    )    ):
															try:
																			snake_case__						=  import_module('.'.join(submodules[: i + 1]    )    )
															except ModuleNotFoundError:
																			continue
															# We iterate over all the globals in self.obj in case we find "os" or "os.path"
															for attr in self.obj.__dir__():
																			snake_case__						=  getattr(self.obj							,						UpperCAmelCase_    )
																			# We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
																			# This allows to patch renamed modules like "from os import path as ospath".
																			if obj_attr is submodule or (
																			    (isinstance(UpperCAmelCase_							,						_PatchedModuleObj    ) and obj_attr._original_module is submodule)
																			):
																							snake_case__						=  obj_attr
																							# patch at top level
																							setattr(self.obj							,						UpperCAmelCase_							,						_PatchedModuleObj(UpperCAmelCase_							,						attrs=self.attrs    )    )
																							snake_case__						=  getattr(self.obj							,						UpperCAmelCase_    )
																							# construct lower levels patches
																							for key in submodules[i + 1 :]:
																											setattr(UpperCAmelCase_							,						UpperCAmelCase_							,						_PatchedModuleObj(getattr(UpperCAmelCase_							,						UpperCAmelCase_							,						UpperCAmelCase_    )							,						attrs=self.attrs    )    )
																											snake_case__						=  getattr(UpperCAmelCase_							,						UpperCAmelCase_    )
																							# finally set the target attribute
																							setattr(UpperCAmelCase_							,						UpperCAmelCase_							,						self.new    )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

											if submodules:  # if it's an attribute of a submodule like "os.path.join"
															try:
																			snake_case__						=  getattr(import_module('.'.join(UpperCAmelCase_    )    )							,						UpperCAmelCase_    )
															except (AttributeError, ModuleNotFoundError):
																			return
															# We iterate over all the globals in self.obj in case we find "os.path.join"
															for attr in self.obj.__dir__():
																			# We don't check for the name of the global, but rather if its value *is* "os.path.join".
																			# This allows to patch renamed attributes like "from os.path import join as pjoin".
																			if getattr(self.obj							,						UpperCAmelCase_    ) is attr_value:
																							snake_case__						=  getattr(self.obj							,						UpperCAmelCase_    )
																							setattr(self.obj							,						UpperCAmelCase_							,						self.new    )
											elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
															snake_case__						=  globals()['__builtins__'][target_attr]
															setattr(self.obj							,						UpperCAmelCase_							,						self.new    )
											else:
															raise RuntimeError(F'''Tried to patch attribute {target_attr} instead of a submodule.'''    )
							def __exit__(  self:   Optional[Any]							,						*UpperCamelCase:   int    )		->		Union[str, Any]:
											for attr in list(self.original    ):
															setattr(self.obj							,						UpperCAmelCase_							,						self.original.pop(UpperCAmelCase_    )    )
							def lowerCAmelCase_			(  self:   Tuple    )		->		str:
											self.__enter__()
											self._active_patches.append(self    )


							def lowerCAmelCase_			(  self:   Dict    )		->		List[Any]:
											try:
															self._active_patches.remove(self    )
											except ValueError:
															# If the patch hasn't been started this will fail
															return None

											return self.__exit__()






"""simple docstring"""


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


if TYPE_CHECKING:
      from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType


SCREAMING_SNAKE_CASE			  =  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE			  =  {
    """microsoft/deberta-v2-xlarge""": """https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/config.json""",
    """microsoft/deberta-v2-xxlarge""": """https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/config.json""",
    """microsoft/deberta-v2-xlarge-mnli""": (
        """https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/config.json"""
    ),
    """microsoft/deberta-v2-xxlarge-mnli""": (
        """https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/config.json"""
    ),
}



class 	__a	(   _lowerCAmelCase						):
       UpperCamelCase_		:       Any				=      '''deberta-v2'''






       def __init__(	self			:				Dict							,   UpperCAmelCase_			:				Optional[int]=128_100							,   UpperCAmelCase_			:				List[str]=1_536							,   UpperCAmelCase_			:				List[str]=24							,   UpperCAmelCase_			:				int=24							,   UpperCAmelCase_			:				int=6_144							,   UpperCAmelCase_			:				Optional[Any]="gelu"							,   UpperCAmelCase_			:				Tuple=0.1							,   UpperCAmelCase_			:				int=0.1							,   UpperCAmelCase_			:				Optional[int]=512							,   UpperCAmelCase_			:				Optional[int]=0							,   UpperCAmelCase_			:				Dict=0.02							,   UpperCAmelCase_			:				Optional[Any]=1e-7							,   UpperCAmelCase_			:				str=False							,   UpperCAmelCase_			:				Tuple=-1							,   UpperCAmelCase_			:				Optional[int]=0							,   UpperCAmelCase_			:				List[str]=True							,   UpperCAmelCase_			:				Any=None							,   UpperCAmelCase_			:				Optional[Any]=0							,   UpperCAmelCase_			:				Optional[Any]="gelu"							,   **UpperCAmelCase_			:				Optional[int]							,   )->	int:







              """simple docstring"""
              super().__init__(**UpperCAmelCase_      )

              UpperCamelCase       			=		hidden_size
              UpperCamelCase       			=		num_hidden_layers
              UpperCamelCase       			=		num_attention_heads
              UpperCamelCase       			=		intermediate_size
              UpperCamelCase       			=		hidden_act
              UpperCamelCase       			=		hidden_dropout_prob
              UpperCamelCase       			=		attention_probs_dropout_prob
              UpperCamelCase       			=		max_position_embeddings
              UpperCamelCase       			=		type_vocab_size
              UpperCamelCase       			=		initializer_range
              UpperCamelCase       			=		relative_attention
              UpperCamelCase       			=		max_relative_positions
              UpperCamelCase       			=		pad_token_id
              UpperCamelCase       			=		position_biased_input

              # Backwards compatibility
              if type(UpperCAmelCase_      ) == str:
                     UpperCamelCase       			=		[x.strip() for x in pos_att_type.lower().split("|"      )]

              UpperCamelCase       			=		pos_att_type
              UpperCamelCase       			=		vocab_size
              UpperCamelCase       			=		layer_norm_eps

              UpperCamelCase       			=		kwargs.get("pooler_hidden_size"							,   UpperCAmelCase_      )
              UpperCamelCase       			=		pooler_dropout
              UpperCamelCase       			=		pooler_hidden_act





class 	__a	(   _lowerCAmelCase						):






       @property
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Mapping[str, Mapping[int, str]]:







              """simple docstring"""
              if self.task == "multiple-choice":
                     UpperCamelCase       			=		{0: "batch", 1: "choice", 2: "sequence"}
              else:
                     UpperCamelCase       			=		{0: "batch", 1: "sequence"}
              if self._config.type_vocab_size > 0:
                     return OrderedDict(
                         [("input_ids", dynamic_axis), ("attention_mask", dynamic_axis), ("token_type_ids", dynamic_axis)]      )
              else:
                     return OrderedDict([("input_ids", dynamic_axis), ("attention_mask", dynamic_axis)]      )






       @property
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Union[str, Any]      )->	int:







              """simple docstring"""
              return 12






       def 						_SCREAMING_SNAKE_CASE							(	self			:				List[str]							,   UpperCAmelCase_			:				Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				bool = False							,   UpperCAmelCase_			:				Optional["TensorType"] = None							,   UpperCAmelCase_			:				int = 3							,   UpperCAmelCase_			:				int = 40							,   UpperCAmelCase_			:				int = 40							,   UpperCAmelCase_			:				"PreTrainedTokenizerBase" = None							,   )->	Mapping[str, Any]:







              """simple docstring"""
              UpperCamelCase       			=		super().generate_dummy_inputs(preprocessor=UpperCAmelCase_							,   framework=UpperCAmelCase_      )
              if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
                     del dummy_inputs["token_type_ids"]
              return dummy_inputs





