


'''simple docstring'''



import os
import string
import sys


A__						:   Tuple				=    1 << 8

A__						:   Dict				=    {
    """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__						:   Optional[int]				=    KEYMAP["""up"""]
A__						:   Optional[int]				=    KEYMAP["""left"""]

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



def      UpperCAmelCase__   (      )	->						int:
     if os.name == "nt":
          import msvcrt

          __lowerCamelCase  :      Any														=						'mbcs'
          # Flush the keyboard buffer
          while msvcrt.kbhit():
               msvcrt.getch()
          if len(UpperCAmelCase_				) == 0:
               # Read the keystroke
               __lowerCamelCase  :      List[Any]														=						msvcrt.getch()

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

          __lowerCamelCase  :      str														=						sys.stdin.fileno()
          __lowerCamelCase  :      Union[str, Any]														=						termios.tcgetattr(UpperCAmelCase_				)
          try:
               tty.setraw(UpperCAmelCase_				)
               __lowerCamelCase  :      Union[str, Any]														=						sys.stdin.read(1				)
          finally:
               termios.tcsetattr(UpperCAmelCase_ ,       termios.TCSADRAIN ,       UpperCAmelCase_				)
     return ch



def      UpperCAmelCase__   (      )	->						List[str]:
     __lowerCamelCase  :      Tuple														=						get_raw_chars()
     if ord(UpperCAmelCase_				) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
          return char

     elif ord(UpperCAmelCase_				) == KEYMAP["esc"]:
          __lowerCamelCase  :      List[str]														=						get_raw_chars()
          if ord(UpperCAmelCase_				) == KEYMAP["mod_int"]:
               __lowerCamelCase  :      Optional[Any]														=						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"]













'''simple docstring'''

from typing import Optional, Union

import torch
from torch import nn

from ...configuration_utils import ConfigMixin, register_to_config
from ...models.modeling_utils import ModelMixin






class   UpperCAmelCase      (			UpperCamelCase__     ,			UpperCamelCase__							):
 @register_to_config
 def __init__(							self :List[str]		,			lowercase_ :int = 7_68		,			)->				str:
     super().__init__()

     A__							=     nn.Parameter(torch.zeros(1		,			lowercase_				)				)
     A__							=     nn.Parameter(torch.ones(1		,			lowercase_				)				)
 def 	UpperCAmelCase_				(							self :List[Any]		,			lowercase_ :Optional[Union[str, torch.device]] = None		,			lowercase_ :Optional[torch.dtype] = None		,			)->				Tuple:
     A__							=     nn.Parameter(self.mean.to(lowercase_				).to(lowercase_				)				)
     A__							=     nn.Parameter(self.std.to(lowercase_				).to(lowercase_				)				)
     return self
 def 	UpperCAmelCase_				(							self :Optional[int]		,			lowercase_ :str				)->				Union[str, Any]:
     A__							=     (embeds - self.mean) * 1.0 / self.std
     return embeds



 def 	UpperCAmelCase_				(							self :Any		,			lowercase_ :List[Any]				)->				Tuple:
     A__							=     (embeds * self.std) + self.mean
     return embeds



