'''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


SCREAMING_SNAKE_CASE_:	Any    =False
try:
    SCREAMING_SNAKE_CASE_:	Optional[Any]    =_is_package_available('google.colab')
except ModuleNotFoundError:
    pass




@input.register
class 			__A :



    def __init__(self       :       int  ,     __a       :       str = None  ,     __a       :       list = []					):
         UpperCAmelCase_			       =  0
         UpperCAmelCase_			       =  choices
         UpperCAmelCase_			       =  prompt
         if sys.platform == "win32":
              UpperCAmelCase_			       =  "*"
         else:
              UpperCAmelCase_			       =  "➔ "



    def    _lowercase		(self       :       Union[str, Any]  ,     __a       :       Optional[int]  ,     __a       :       str = ""					):
         if sys.platform != "win32":
              writeColor(self.choices[index]  ,     32  ,     __a					)
         else:
              forceWrite(self.choices[index]  ,     __a					)



    def    _lowercase		(self       :       Any  ,     __a       :       int					):
         if index == self.position:
              forceWrite(f""" {self.arrow_char} """					)
              self.write_choice(__a					)
         else:
              forceWrite(f"""    {self.choices[index]}"""					)
         reset_cursor()



    def    _lowercase		(self       :       Optional[Any]  ,     __a       :       Direction  ,     __a       :       int = 1					):
         UpperCAmelCase_			       =  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    _lowercase		(self       :       Dict					):
         self.move_direction(Direction.UP					)



    @input.mark(KEYMAP["down"]					)
    def    _lowercase		(self       :       Any					):
         self.move_direction(Direction.DOWN					)



    @input.mark(KEYMAP["newline"]					)
    def    _lowercase		(self       :       Optional[Any]					):
         move_cursor(len(self.choices					) - self.position  ,     "DOWN"					)
         return self.position



    @input.mark(KEYMAP["interrupt"]					)
    def    _lowercase		(self       :       str					):
         move_cursor(len(self.choices					) - self.position  ,     "DOWN"					)
         raise KeyboardInterrupt



    @input.mark_multiple(*[KEYMAP[str(__a					)] for number in range(10					)]					)
    def    _lowercase		(self       :       Union[str, Any]					):
         UpperCAmelCase_			       =  int(chr(self.current_selection					)					)
         UpperCAmelCase_			       =  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    _lowercase		(self       :       Optional[Any]  ,     __a       :       int = 0					):
         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_			       =  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_			       =  int(builtins.input()					)
                        except ValueError:
                             UpperCAmelCase_			       =  default_choice
                   else:
                        UpperCAmelCase_			       =  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





from ...configuration_utils import PretrainedConfig
from ...utils import logging


a  :      List[Any]            =    logging.get_logger(__name__)

a  :      Union[str, Any]            =    {
    """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""",
}

class 					_lowercase    (     UpperCAmelCase__			):






    '''simple docstring'''
    SCREAMING_SNAKE_CASE:				List[str]          =    'gpt_bigcode'
    SCREAMING_SNAKE_CASE:				Union[str, Any]          =    ['past_key_values']
    SCREAMING_SNAKE_CASE:				Tuple          =    {
        'hidden_size': 'n_embd',
        'max_position_embeddings': 'n_positions',
        'num_attention_heads': 'n_head',
        'num_hidden_layers': 'n_layer',
    }




    def __init__(    self       ,						lowerCamelCase__=50_257       ,						lowerCamelCase__=1_024       ,						lowerCamelCase__=768       ,						lowerCamelCase__=12       ,						lowerCamelCase__=12       ,						lowerCamelCase__=None       ,						lowerCamelCase__="gelu_pytorch_tanh"       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=1E-5       ,						lowerCamelCase__=0.0_2       ,						lowerCamelCase__=True       ,						lowerCamelCase__=True       ,						lowerCamelCase__=50_256       ,						lowerCamelCase__=50_256       ,						lowerCamelCase__=True       ,						lowerCamelCase__=True       ,						lowerCamelCase__=True       ,						**lowerCamelCase__       ,						):
       lowerCAmelCase_:							List[Any]       =	vocab_size
       lowerCAmelCase_:							List[str]       =	n_positions
       lowerCAmelCase_:							Union[str, Any]       =	n_embd
       lowerCAmelCase_:							Union[str, Any]       =	n_layer
       lowerCAmelCase_:							Union[str, Any]       =	n_head
       lowerCAmelCase_:							List[Any]       =	n_inner
       lowerCAmelCase_:							List[Any]       =	activation_function
       lowerCAmelCase_:							Optional[int]       =	resid_pdrop
       lowerCAmelCase_:							Union[str, Any]       =	embd_pdrop
       lowerCAmelCase_:							Any       =	attn_pdrop
       lowerCAmelCase_:							Union[str, Any]       =	layer_norm_epsilon
       lowerCAmelCase_:							Optional[Any]       =	initializer_range
       lowerCAmelCase_:							int       =	scale_attn_weights
       lowerCAmelCase_:							int       =	use_cache
       lowerCAmelCase_:							int       =	attention_softmax_in_fpaa
       lowerCAmelCase_:							int       =	scale_attention_softmax_in_fpaa
       lowerCAmelCase_:							Union[str, Any]       =	multi_query

       lowerCAmelCase_:							Union[str, Any]       =	bos_token_id
       lowerCAmelCase_:							List[str]       =	eos_token_id

       super().__init__(bos_token_id=lowerCamelCase__       ,						eos_token_id=lowerCamelCase__       ,						**lowerCamelCase__ )