
"""simple docstring"""







import os
import string
import sys


_SCREAMING_SNAKE_CASE													=   1 << 8

_SCREAMING_SNAKE_CASE													=   {
    """tab""": ord("""\t"""),
    """newline""": ord("""\r"""),
    """esc""": 27,
    """up""": 65 + ARROW_KEY_FLAG,
    """down""": 66 + ARROW_KEY_FLAG,
    """right""": 67 + ARROW_KEY_FLAG,
    """left""": 68 + ARROW_KEY_FLAG,
    """mod_int""": 91,
    """undefined""": sys.maxsize,
    """interrupt""": 3,
    """insert""": 50,
    """delete""": 51,
    """pg_up""": 53,
    """pg_down""": 54,
}

_SCREAMING_SNAKE_CASE													=   KEYMAP["""up"""]
_SCREAMING_SNAKE_CASE													=   KEYMAP["""left"""]

if sys.platform == "win32":
		_SCREAMING_SNAKE_CASE													=   []
		_SCREAMING_SNAKE_CASE													=   {
		    B"""\xe0H""": KEYMAP["""up"""] - ARROW_KEY_FLAG,
		    B"""\x00H""": KEYMAP["""up"""] - ARROW_KEY_FLAG,
		    B"""\xe0P""": KEYMAP["""down"""] - ARROW_KEY_FLAG,
		    B"""\x00P""": KEYMAP["""down"""] - ARROW_KEY_FLAG,
		    B"""\xe0M""": KEYMAP["""right"""] - ARROW_KEY_FLAG,
		    B"""\x00M""": KEYMAP["""right"""] - ARROW_KEY_FLAG,
		    B"""\xe0K""": KEYMAP["""left"""] - ARROW_KEY_FLAG,
		    B"""\x00K""": KEYMAP["""left"""] - ARROW_KEY_FLAG,
		}

for i in range(10):
		_SCREAMING_SNAKE_CASE													=   ord(str(i))
def 	__UpperCamelCase (       )	->  Union[str, Any]:







							"""simple docstring"""


							if os.name == "nt":
														import msvcrt

														__snake_case        =							"mbcs"
														# Flush the keyboard buffer
														while msvcrt.kbhit():
																					msvcrt.getch()
														if len(__UpperCamelCase			) == 0:
																					# Read the keystroke
																					__snake_case        =							msvcrt.getch()

																					# If it is a prefix char, get second part
																					if ch in (b"\x00", b"\xe0"):
																												__snake_case        =							ch + msvcrt.getch()
																												# Translate actual Win chars to bullet char types
																												try:
																																			__snake_case        =							chr(WIN_KEYMAP[cha]			)
																																			WIN_CH_BUFFER.append(chr(KEYMAP["mod_int"]			)			)
																																			WIN_CH_BUFFER.append(__UpperCamelCase			)
																																			if ord(__UpperCamelCase			) in (
																																			    KEYMAP["insert"] - 1 << 9,
																																			    KEYMAP["delete"] - 1 << 9,
																																			    KEYMAP["pg_up"] - 1 << 9,
																																			    KEYMAP["pg_down"] - 1 << 9,
																																			):
																																										WIN_CH_BUFFER.append(chr(1_26			)			)
																																			__snake_case        =							chr(KEYMAP["esc"]			)
																												except KeyError:
																																			__snake_case        =							cha[1]
																					else:
																												__snake_case        =							ch.decode(__UpperCamelCase			)
														else:
																					__snake_case        =							WIN_CH_BUFFER.pop(0			)
							elif os.name == "posix":
														import termios
														import tty

														__snake_case        =							sys.stdin.fileno()
														__snake_case        =							termios.tcgetattr(__UpperCamelCase			)
														try:
																					tty.setraw(__UpperCamelCase			)
																					__snake_case        =							sys.stdin.read(1			)
														finally:
																					termios.tcsetattr(__UpperCamelCase				,     termios.TCSADRAIN				,     __UpperCamelCase			)
							return ch



def 	__UpperCamelCase (       )	->  Dict:







							"""simple docstring"""


							__snake_case        =							get_raw_chars()
							if ord(__UpperCamelCase			) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
														return char

							elif ord(__UpperCamelCase			) == KEYMAP["esc"]:
														__snake_case        =							get_raw_chars()
														if ord(__UpperCamelCase			) == KEYMAP["mod_int"]:
																					__snake_case        =							get_raw_chars()
																					if ord(__UpperCamelCase			) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__UpperCamelCase			) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
																												return chr(ord(__UpperCamelCase			) + ARROW_KEY_FLAG			)
																					else:
																												return KEYMAP["undefined"]
														else:
																					return get_raw_chars()

							else:
														if char in string.printable:
																					return char
														else:
																					return KEYMAP["undefined"]





# 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

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


SCREAMING_SNAKE_CASE__   			=   {'''configuration_mra''': ['''MRA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MraConfig''']}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							SCREAMING_SNAKE_CASE__   			=   [
							    '''MRA_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''MraForMaskedLM''',
							    '''MraForMultipleChoice''',
							    '''MraForQuestionAnswering''',
							    '''MraForSequenceClassification''',
							    '''MraForTokenClassification''',
							    '''MraLayer''',
							    '''MraModel''',
							    '''MraPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_mra import MRA_PRETRAINED_CONFIG_ARCHIVE_MAP, MraConfig

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_mra import (
														    MRA_PRETRAINED_MODEL_ARCHIVE_LIST,
														    MraForMaskedLM,
														    MraForMultipleChoice,
														    MraForQuestionAnswering,
														    MraForSequenceClassification,
														    MraForTokenClassification,
														    MraLayer,
														    MraModel,
														    MraPreTrainedModel,
														)
else:
							import sys

							SCREAMING_SNAKE_CASE__   			=   _LazyModule(__name__, globals()['''__file__'''], _import_structure)




