




from typing import Mapping

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


a													=			logging.get_logger(__name__)

a													=			{
    "t5-small": "https://huggingface.co/t5-small/resolve/main/config.json",
    "t5-base": "https://huggingface.co/t5-base/resolve/main/config.json",
    "t5-large": "https://huggingface.co/t5-large/resolve/main/config.json",
    "t5-3b": "https://huggingface.co/t5-3b/resolve/main/config.json",
    "t5-11b": "https://huggingface.co/t5-11b/resolve/main/config.json",
}




class       _A				(		__lowercase     ):
		__a					    =       """t5"""
		__a					    =       ["""past_key_values"""]
		__a					    =       {"""hidden_size""": """d_model""", """num_attention_heads""": """num_heads""", """num_hidden_layers""": """num_layers"""}






		def __init__(    self						,		_SCREAMING_SNAKE_CASE=3_2128						,		_SCREAMING_SNAKE_CASE=512						,		_SCREAMING_SNAKE_CASE=64						,		_SCREAMING_SNAKE_CASE=2048						,		_SCREAMING_SNAKE_CASE=6						,		_SCREAMING_SNAKE_CASE=None						,		_SCREAMING_SNAKE_CASE=8						,		_SCREAMING_SNAKE_CASE=32						,		_SCREAMING_SNAKE_CASE=128						,		_SCREAMING_SNAKE_CASE=0.1						,		_SCREAMING_SNAKE_CASE=1e-6						,		_SCREAMING_SNAKE_CASE=1.0						,		_SCREAMING_SNAKE_CASE="relu"						,		_SCREAMING_SNAKE_CASE=True						,		_SCREAMING_SNAKE_CASE=True						,		_SCREAMING_SNAKE_CASE=0						,		_SCREAMING_SNAKE_CASE=1						,		**_SCREAMING_SNAKE_CASE						,		):
								_UpperCAmelCase      =			vocab_size
								_UpperCAmelCase      =			d_model
								_UpperCAmelCase      =			d_kv
								_UpperCAmelCase      =			d_ff
								_UpperCAmelCase      =			num_layers
								_UpperCAmelCase      =			(
								    num_decoder_layers if num_decoder_layers is not None else self.num_layers
								)  # default = symmetry
								_UpperCAmelCase      =			num_heads
								_UpperCAmelCase      =			relative_attention_num_buckets
								_UpperCAmelCase      =			relative_attention_max_distance
								_UpperCAmelCase      =			dropout_rate
								_UpperCAmelCase      =			layer_norm_epsilon
								_UpperCAmelCase      =			initializer_factor
								_UpperCAmelCase      =			feed_forward_proj
								_UpperCAmelCase      =			use_cache

								_UpperCAmelCase      =			self.feed_forward_proj.split("""-"""			)
								_UpperCAmelCase      =			act_info[-1]
								_UpperCAmelCase      =			act_info[0] == """gated"""

								if len(_SCREAMING_SNAKE_CASE			) > 1 and act_info[0] != "gated" or len(_SCREAMING_SNAKE_CASE			) > 2:
														raise ValueError(
														    F"`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer."
														    """Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. """
														    """'gated-gelu' or 'relu'"""			)

								# for backwards compatibility
								if feed_forward_proj == "gated-gelu":
														_UpperCAmelCase      =			"""gelu_new"""

								super().__init__(
								    pad_token_id=_SCREAMING_SNAKE_CASE						,		eos_token_id=_SCREAMING_SNAKE_CASE						,		is_encoder_decoder=_SCREAMING_SNAKE_CASE						,		**_SCREAMING_SNAKE_CASE						,		)




class       _A				(		__lowercase     ):






		@property
		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			{
								    """input_ids""": {0: """batch""", 1: """encoder_sequence"""},
								    """attention_mask""": {0: """batch""", 1: """encoder_sequence"""},
								}
								if self.use_past:
														_UpperCAmelCase      =			"""past_encoder_sequence + sequence"""
														_UpperCAmelCase      =			{0: """batch"""}
														_UpperCAmelCase      =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
								else:
														_UpperCAmelCase      =			{0: """batch""", 1: """decoder_sequence"""}
														_UpperCAmelCase      =			{0: """batch""", 1: """decoder_sequence"""}

								if self.use_past:
														self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE						,		direction="""inputs"""			)

								return common_inputs






		@property
		def 				UpperCAmelCase (    self			):
								return 13





import os
import string
import sys


a													=			1 << 8

a													=			{
    "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,
}

a													=			KEYMAP["up"]
a													=			KEYMAP["left"]

if sys.platform == "win32":
				a													=			[]
				a													=			{
				    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):
				a													=			ord(str(i))




def        _SCREAMING_SNAKE_CASE      (		)						->				Optional[int]:
						if os.name == "nt":
												import msvcrt

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

																		# If it is a prefix char, get second part
																		if ch in (b"\x00", b"\xe0"):
																								_UpperCAmelCase      =			ch + msvcrt.getch()
																								# Translate actual Win chars to bullet char types
																								try:
																														_UpperCAmelCase      =			chr(WIN_KEYMAP[cha]       )
																														WIN_CH_BUFFER.append(chr(KEYMAP["""mod_int"""]       )       )
																														WIN_CH_BUFFER.append(snake_case       )
																														if ord(snake_case       ) 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_2_6       )       )
																														_UpperCAmelCase      =			chr(KEYMAP["""esc"""]       )
																								except KeyError:
																														_UpperCAmelCase      =			cha[1]
																		else:
																								_UpperCAmelCase      =			ch.decode(snake_case       )
												else:
																		_UpperCAmelCase      =			WIN_CH_BUFFER.pop(0       )
						elif os.name == "posix":
												import termios
												import tty

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




def        _SCREAMING_SNAKE_CASE      (		)						->				Dict:
						_UpperCAmelCase      =			get_raw_chars()
						if ord(snake_case       ) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
												return char

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

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