

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


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

lowerCAmelCase							:  Optional[int]   	=						{"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""}



class   __lowercase				( UpperCAmelCase_	):




			"""simple docstring"""







			_UpperCAmelCase   :							Dict										=     '''ctrl'''
			_UpperCAmelCase   :							Dict										=     ['''past_key_values''']
			_UpperCAmelCase   :							Optional[int]										=     {
			    '''max_position_embeddings''': '''n_positions''',
			    '''hidden_size''': '''n_embd''',
			    '''num_attention_heads''': '''n_head''',
			    '''num_hidden_layers''': '''n_layer''',
			}



			def __init__( self  :     str   ,						lowerCAmelCase__  :     Tuple=24_6534   ,						lowerCAmelCase__  :     Tuple=256   ,						lowerCAmelCase__  :     List[str]=1280   ,						lowerCAmelCase__  :     List[Any]=8192   ,						lowerCAmelCase__  :     Union[str, Any]=48   ,						lowerCAmelCase__  :     Any=16   ,						lowerCAmelCase__  :     Union[str, Any]=0.1   ,						lowerCAmelCase__  :     Union[str, Any]=0.1   ,						lowerCAmelCase__  :     Any=1E-6   ,						lowerCAmelCase__  :     int=0.02   ,						lowerCAmelCase__  :     Any=True   ,						**lowerCAmelCase__  :     Union[str, Any]   ,						):
									SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       vocab_size
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       n_positions
									SCREAMING_SNAKE_CASE_: List[Any]  		=       n_embd
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       n_layer
									SCREAMING_SNAKE_CASE_: Tuple  		=       n_head
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       dff
									SCREAMING_SNAKE_CASE_: str  		=       resid_pdrop
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       embd_pdrop
									SCREAMING_SNAKE_CASE_: str  		=       layer_norm_epsilon
									SCREAMING_SNAKE_CASE_: str  		=       initializer_range

									SCREAMING_SNAKE_CASE_: List[Any]  		=       use_cache

									super().__init__(**lowerCAmelCase__)










'''simple docstring'''






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


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

__A					:  Optional[Any]											=      {
    "EleutherAI/gpt-neox-20b": "https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json",
    # See all GPTNeoX models at https://huggingface.co/models?filter=gpt_neox
}






class    __snake_case       (   _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase    =					'gpt_neox'

    def __init__(   self    :  Optional[int]    ,						lowerCamelCase    :  Tuple=5_04_32    ,						lowerCamelCase    :  Optional[int]=61_44    ,						lowerCamelCase    :  Tuple=44    ,						lowerCamelCase    :  Any=64    ,						lowerCamelCase    :  List[Any]=2_45_76    ,						lowerCamelCase    :  List[Any]="gelu"    ,						lowerCamelCase    :  Optional[Any]=0.25    ,						lowerCamelCase    :  Any=1_00_00    ,						lowerCamelCase    :  Any=0.0    ,						lowerCamelCase    :  str=0.0    ,						lowerCamelCase    :  Optional[int]=0.1    ,						lowerCamelCase    :  List[Any]=20_48    ,						lowerCamelCase    :  List[Any]=0.02    ,						lowerCamelCase    :  Any=1E-5    ,						lowerCamelCase    :  Dict=True    ,						lowerCamelCase    :  Optional[int]=0    ,						lowerCamelCase    :  List[str]=2    ,						lowerCamelCase    :  Dict=False    ,						lowerCamelCase    :  Tuple=True    ,						lowerCamelCase    :  Optional[int]=None    ,						**lowerCamelCase    :  int    ,						)   ->  Optional[Any]:
      super().__init__(bos_token_id=lowerCamelCase    ,						eos_token_id=lowerCamelCase    ,						**lowerCamelCase		)
      lowerCAmelCase_			:      Tuple			=   vocab_size
      lowerCAmelCase_			:      Union[str, Any]			=   max_position_embeddings
      lowerCAmelCase_			:      Any			=   hidden_size
      lowerCAmelCase_			:      List[Any]			=   num_hidden_layers
      lowerCAmelCase_			:      Optional[int]			=   num_attention_heads
      lowerCAmelCase_			:      str			=   intermediate_size
      lowerCAmelCase_			:      int			=   hidden_act
      lowerCAmelCase_			:      List[Any]			=   rotary_pct
      lowerCAmelCase_			:      Any			=   rotary_emb_base
      lowerCAmelCase_			:      List[str]			=   attention_dropout
      lowerCAmelCase_			:      Union[str, Any]			=   hidden_dropout
      lowerCAmelCase_			:      Tuple			=   classifier_dropout
      lowerCAmelCase_			:      Union[str, Any]			=   initializer_range
      lowerCAmelCase_			:      Any			=   layer_norm_eps
      lowerCAmelCase_			:      str			=   use_cache
      lowerCAmelCase_			:      str			=   tie_word_embeddings
      lowerCAmelCase_			:      str			=   use_parallel_residual
      lowerCAmelCase_			:      Any			=   rope_scaling
      self._rope_scaling_validation()

      if self.hidden_size % self.num_attention_heads != 0:
        raise ValueError(
            """The hidden size is not divisble by the number of attention heads! Make sure to update them!"""		)





    def __lowercase   (   self    :  List[str]		)   ->  List[str]:
      if self.rope_scaling is None:
        return

      if not isinstance(self.rope_scaling    ,						lowerCamelCase		) or len(self.rope_scaling		) != 2:
        raise ValueError(
            """`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, """
            F'got {self.rope_scaling}'		)
      lowerCAmelCase_			:      Optional[Any]			=   self.rope_scaling.get("""type"""    ,						lowerCamelCase		)
      lowerCAmelCase_			:      int			=   self.rope_scaling.get("""factor"""    ,						lowerCamelCase		)
      if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
        raise ValueError(
            F'`rope_scaling`\'s name field must be one of [\'linear\', \'dynamic\'], got {rope_scaling_type}'		)
      if rope_scaling_factor is None or not isinstance(lowerCamelCase    ,						lowerCamelCase		) or rope_scaling_factor <= 1.0:
        raise ValueError(F'`rope_scaling`\'s factor field must be an float > 1, got {rope_scaling_factor}'		)



