


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


A			:						Optional[int]        =  logging.get_logger(__name__)

A			:						Optional[Any]        =  {
    '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       (			UpperCAmelCase__				):
					'''simple docstring'''






					A__     =					'''deberta-v2'''

					def __init__(self       :		Optional[Any] ,   _UpperCAmelCase       :		Any=12_8100 ,   _UpperCAmelCase       :		List[Any]=1536 ,   _UpperCAmelCase       :		List[Any]=24 ,   _UpperCAmelCase       :		List[Any]=24 ,   _UpperCAmelCase       :		Optional[int]=6144 ,   _UpperCAmelCase       :		Tuple="gelu" ,   _UpperCAmelCase       :		List[Any]=0.1 ,   _UpperCAmelCase       :		Tuple=0.1 ,   _UpperCAmelCase       :		str=512 ,   _UpperCAmelCase       :		List[str]=0 ,   _UpperCAmelCase       :		Union[str, Any]=0.02 ,   _UpperCAmelCase       :		Dict=1E-7 ,   _UpperCAmelCase       :		Optional[Any]=False ,   _UpperCAmelCase       :		Tuple=-1 ,   _UpperCAmelCase       :		Optional[int]=0 ,   _UpperCAmelCase       :		Optional[Any]=True ,   _UpperCAmelCase       :		Optional[Any]=None ,   _UpperCAmelCase       :		Optional[int]=0 ,   _UpperCAmelCase       :		Optional[int]="gelu" ,   **_UpperCAmelCase       :		Tuple ,   )		->  List[Any]:




							"""simple docstring"""


							super().__init__(**_UpperCAmelCase						)

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

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

							lowercase__	     =						pos_att_type
							lowercase__	     =						vocab_size
							lowercase__	     =						layer_norm_eps

							lowercase__	     =						kwargs.get("""pooler_hidden_size""" ,   _UpperCAmelCase						)
							lowercase__	     =						pooler_dropout
							lowercase__	     =						pooler_hidden_act






class 				A       (			UpperCAmelCase__				):
					'''simple docstring'''






					@property
					def     lowerCamelCase__	(self       :		str						)		->  Mapping[str, Mapping[int, str]]:




							"""simple docstring"""


							if self.task == "multiple-choice":
									lowercase__	     =						{0: """batch""", 1: """choice""", 2: """sequence"""}
							else:
									lowercase__	     =						{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     lowerCamelCase__	(self       :		int						)		->  int:




							"""simple docstring"""


							return 12


					def     lowerCamelCase__	(self       :		List[Any] ,   _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"""


							lowercase__	     =						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








"""simple docstring"""


import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


lowerCamelCase__						= False
try:
  lowerCamelCase__						= _is_package_available("google.colab")
except ModuleNotFoundError:
  pass



@input.register
class   __SCREAMING_SNAKE_CASE     :







  '''simple docstring'''


  def __init__(		self :							Union[str, Any]       , __a :							str = None       , __a :							list = []						)		->					Union[str, Any]:
        _UpperCamelCase   :						Any    =							0
        _UpperCamelCase   :						Any    =							choices
        _UpperCamelCase   :						Tuple    =							prompt
        if sys.platform == "win32":
              _UpperCamelCase   :						str    =							"*"
        else:
              _UpperCamelCase   :						Dict    =							"➔ "

  def  __SCREAMING_SNAKE_CASE					(		self :							int       , __a :							Tuple       , __a :							str = ""						)		->					Dict:
        if sys.platform != "win32":
              writeColor(self.choices[index]       , 32       , __a						)
        else:
              forceWrite(self.choices[index]       , __a						)

  def  __SCREAMING_SNAKE_CASE					(		self :							Tuple       , __a :							int						)		->					Dict:
        if index == self.position:
              forceWrite(F''' {self.arrow_char} '''						)
              self.write_choice(__a						)
        else:
              forceWrite(F'''    {self.choices[index]}'''						)
        reset_cursor()

  def  __SCREAMING_SNAKE_CASE					(		self :							List[str]       , __a :							Direction       , __a :							int = 1						)		->					List[str]:
        _UpperCamelCase   :						Tuple    =							self.position
        if direction == Direction.DOWN:
              if self.position + 1 >= len(self.choices						):
                    return
              self.position += num_spaces
        else:
              if self.position - 1 < 0:
                    return
              self.position -= num_spaces
        clear_line()
        self.print_choice(__a						)
        move_cursor(__a       , direction.name						)
        self.print_choice(self.position						)

  @input.mark(KEYMAP["up"]						)
  def  __SCREAMING_SNAKE_CASE					(		self :							Union[str, Any]						)		->					Any:
        self.move_direction(Direction.UP						)

  @input.mark(KEYMAP["down"]						)
  def  __SCREAMING_SNAKE_CASE					(		self :							Dict						)		->					List[Any]:
        self.move_direction(Direction.DOWN						)

  @input.mark(KEYMAP["newline"]						)
  def  __SCREAMING_SNAKE_CASE					(		self :							int						)		->					str:
        move_cursor(len(self.choices						) - self.position       , "DOWN"						)
        return self.position

  @input.mark(KEYMAP["interrupt"]						)
  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[Any]						)		->					Tuple:
        move_cursor(len(self.choices						) - self.position       , "DOWN"						)
        raise KeyboardInterrupt

  @input.mark_multiple(*[KEYMAP[str(__a						)] for number in range(10						)]						)
  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[int]						)		->					List[str]:
        _UpperCamelCase   :						Union[str, Any]    =							int(chr(self.current_selection						)						)
        _UpperCamelCase   :						List[str]    =							index - self.position
        if index == self.position:
              return
        if index < len(self.choices						):
              if self.position > index:
                    self.move_direction(Direction.UP       , -movement						)
              elif self.position < index:
                    self.move_direction(Direction.DOWN       , __a						)
              else:
                    return
        else:
              return


  def  __SCREAMING_SNAKE_CASE					(		self :							List[Any]       , __a :							int = 0						)		->					List[Any]:
        if self.prompt:
              linebreak()
              forceWrite(self.prompt       , "\n"						)
              if in_colab:
                    forceWrite("Please input a choice index (starting from 0), and press enter"       , "\n"						)
              else:
                    forceWrite("Please select a choice using the arrow or number keys, and selecting with enter"       , "\n"						)
        _UpperCamelCase   :						int    =							default_choice
        for i in range(len(self.choices						)						):
              self.print_choice(__a						)
              forceWrite("\n"						)
        move_cursor(len(self.choices						) - self.position       , "UP"						)
        with cursor.hide():
              while True:
                    if in_colab:
                          try:
                                _UpperCamelCase   :						Union[str, Any]    =							int(builtins.input()						)
                          except ValueError:
                                _UpperCamelCase   :						int    =							default_choice
                    else:
                          _UpperCamelCase   :						Any    =							self.handle_input()
                    if choice is not None:
                          reset_cursor()
                          for _ in range(len(self.choices						) + 1						):
                                move_cursor(1       , "UP"						)
                                clear_line()
                          self.write_choice(__a       , "\n"						)
                          return choice
