






'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase__			=      logging.get_logger(__name__)

UpperCamelCase__			=      {
    'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json',
    'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json',
}


class 							_UpperCAmelCase    (		snake_case      ):
    __lowerCamelCase: Optional[int]									=     'falcon'
    __lowerCamelCase: Optional[int]									=     ['past_key_values']




    def __init__(      self	:							Any	,  a	:							int=6_5_0_2_4	,  a	:							Tuple=4_5_4_4	,  a	:							int=3_2	,  a	:							Any=7_1	,  a	:							Optional[Any]=1e-5	,  a	:							Dict=0.02	,  a	:							Any=True	,  a	:							Any=0.0	,  a	:							List[Any]=0.0	,  a	:							Union[str, Any]=None	,  a	:							Tuple=False	,  a	:							List[Any]=False	,  a	:							Optional[Any]=True	,  a	:							Tuple=True	,  a	:							Optional[Any]=False	,  a	:							Any=1_1	,  a	:							Optional[int]=1_1	,  **a	:							int	,  ):






       '''simple docstring'''






       lowercase_						:     Optional[int]							     =  vocab_size
       # Backward compatibility with n_embed kwarg
       lowercase_						:     Optional[int]							     =  kwargs.pop("n_embed"	,  a      )
       lowercase_						:     Any							     =  hidden_size if n_embed is None else n_embed
       lowercase_						:     Tuple							     =  num_hidden_layers
       lowercase_						:     Union[str, Any]							     =  num_attention_heads
       lowercase_						:     int							     =  layer_norm_epsilon
       lowercase_						:     Union[str, Any]							     =  initializer_range
       lowercase_						:     Tuple							     =  use_cache
       lowercase_						:     Optional[int]							     =  hidden_dropout
       lowercase_						:     List[str]							     =  attention_dropout

       lowercase_						:     List[Any]							     =  bos_token_id
       lowercase_						:     List[str]							     =  eos_token_id
       lowercase_						:     Optional[int]							     =  num_attention_heads if num_kv_heads is None else num_kv_heads
       lowercase_						:     List[Any]							     =  alibi
       lowercase_						:     Optional[Any]							     =  new_decoder_architecture
       lowercase_						:     Tuple							     =  multi_query  # Ignored when new_decoder_architecture is True
       lowercase_						:     Dict							     =  parallel_attn
       lowercase_						:     int							     =  bias

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




    @property
    def 					lowerCAmelCase__					(      self	:							Tuple      ):






       '''simple docstring'''






       return self.hidden_size // self.num_attention_heads





    @property
    def 					lowerCAmelCase__					(      self	:							Union[str, Any]      ):






       '''simple docstring'''






       return not self.alibi












'''simple docstring'''
import argparse
import os

import torch

from transformers.utils import WEIGHTS_NAME


UpperCamelCase__			=      ['small', 'medium', 'large']

UpperCamelCase__			=      'lm_head.decoder.weight'
UpperCamelCase__			=      'lm_head.weight'




def 		__SCREAMING_SNAKE_CASE       (	_UpperCamelCase    ,		_UpperCamelCase				):


   """simple docstring"""




   lowercase_						:     Optional[Any]							     =  torch.load(_UpperCamelCase				)
   lowercase_						:     List[Any]							     =  d.pop(_UpperCamelCase				)
   os.makedirs(_UpperCamelCase    ,		exist_ok=_UpperCamelCase				)
   torch.save(_UpperCamelCase    ,		os.path.join(_UpperCamelCase    ,		_UpperCamelCase				)				)


if __name__ == "__main__":
 UpperCamelCase__			=      argparse.ArgumentParser()
 parser.add_argument('--dialogpt_path', default='.', type=str)
 UpperCamelCase__			=      parser.parse_args()
 for MODEL in DIALOGPT_MODELS:
  UpperCamelCase__			=      os.path.join(args.dialogpt_path, f"""{MODEL}_ft.pkl""")
  UpperCamelCase__			=      f"""./DialoGPT-{MODEL}"""
  convert_dialogpt_checkpoint(
      checkpoint_path,
      pytorch_dump_folder_path,
  )




