code: 
  
  
  from typing import Literal
  
  UpperCamelCase__				       =			'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  
  def   UpperCamelCase__   (    UpperCAmelCase_    ,     UpperCAmelCase_    ,     UpperCAmelCase_			)						->							str:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         _lowercase					:				Optional[Any]           =			LETTERS if mode == '''decrypt''' else key
         _lowercase					:				Dict           =			key if mode == '''decrypt''' else LETTERS
         _lowercase					:				str           =			''''''
         # loop through each symbol in the message
         for symbol in message:
                if symbol.upper() in chars_a:
                       # encrypt/decrypt the symbol
                       _lowercase					:				str           =			chars_a.find(symbol.upper()			)
                       if symbol.isupper():
                              translated += chars_b[sym_index].upper()
                       else:
                              translated += chars_b[sym_index].lower()
                else:
                       # symbol is not in LETTERS, just add it
                       translated += symbol
         return translated
  
  def   UpperCamelCase__   (    UpperCAmelCase_    ,     UpperCAmelCase_			)						->							str:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         return translate_message(lowercase__    ,     lowercase__    ,     '''encrypt'''			)
  
  def   UpperCamelCase__   (    UpperCAmelCase_    ,     UpperCAmelCase_			)						->							str:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         return translate_message(lowercase__    ,     lowercase__    ,     '''decrypt'''			)
  
  def   UpperCamelCase__   (    )						->							None:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         _lowercase					:				Optional[Any]           =			'''Hello World'''
         _lowercase					:				Tuple           =			'''QWERTYUIOPASDFGHJKLZXCVBNM'''
         _lowercase					:				Optional[int]           =			'''decrypt'''  # set to 'encrypt' or 'decrypt'
  
         if mode == "encrypt":
                _lowercase					:				Any           =			encrypt_message(lowercase__    ,     lowercase__			)
         elif mode == "decrypt":
                _lowercase					:				List[Any]           =			decrypt_message(lowercase__    ,     lowercase__			)
         print(F'Using the key {key}, the {mode}ed message is: {translated}'			)
  
  
  if __name__ == "__main__":
     import doctest
  
     doctest.testmod()
     main()
style_context: 
  
  
  import os
  from pathlib import Path
  from typing import Dict, List
  
  import fire
  import torch
  
  from transformers import AutoModelForSeqaSeqLM, AutoTokenizer
  from transformers.utils.logging import get_logger
  
  
  UpperCamelCase__				       =			get_logger(__name__)
  
  def   UpperCamelCase__   (    UpperCAmelCase_    ,     UpperCAmelCase_			)						->							List[str]:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         if text.startswith(UpperCAmelCase_			):
                return text[len(UpperCAmelCase_			) :]
         return text  # or whatever
  
  def   UpperCamelCase__   (    UpperCAmelCase_			)						->							Optional[int]:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         return {remove_prefix(UpperCAmelCase_    ,     '''model.'''			): v for k, v in sd.items()}
  
  def   UpperCamelCase__   (    UpperCAmelCase_			)						->							Any:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         _lowercase					:				Optional[int]           =			{}
         for k in state_dicts[0].keys():
                _lowercase					:				Tuple           =			[sd[k] for sd in state_dicts]
                _lowercase					:				Union[str, Any]           =			sum(UpperCAmelCase_			) / len(UpperCAmelCase_			)
                assert isinstance(UpperCAmelCase_    ,     torch.Tensor			)
                _lowercase					:				Union[str, Any]           =			new_t
         return new_sd
  
  def   UpperCamelCase__   (    UpperCAmelCase_    ,     UpperCAmelCase_    ,     UpperCAmelCase_			)						->							None:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         _lowercase					:				List[str]           =			AutoModelForSeqaSeqLM.from_pretrained(UpperCAmelCase_			)
         if os.path.isfile(UpperCAmelCase_			):
                _lowercase					:				Optional[Any]           =			[pl_ckpt_path]
         else:
                assert os.path.isdir(UpperCAmelCase_			)
                _lowercase					:				List[str]           =			list(Path(UpperCAmelCase_			).glob('''*.ckpt'''			)			)
                assert ckpt_files, F'could not find any ckpt files inside the {pl_ckpt_path} directory'
  
         if len(UpperCAmelCase_			) > 1:
                logger.info(F'averaging the weights of {ckpt_files}'			)
  
         _lowercase					:				List[Any]           =			[sanitize(torch.load(UpperCAmelCase_    ,     map_location='''cpu'''			)['''state_dict''']			) for x in ckpt_files]
         _lowercase					:				Optional[Any]           =			average_state_dicts(UpperCAmelCase_			)
  
         _lowercase       ,	_lowercase					:				str           =			hf_model.load_state_dict(UpperCAmelCase_    ,     strict=UpperCAmelCase_			)
         assert not missing, F'missing keys: {missing}'
         hf_model.save_pretrained(UpperCAmelCase_			)
         try:
                _lowercase					:				Union[str, Any]           =			AutoTokenizer.from_pretrained(UpperCAmelCase_			)
                tok.save_pretrained(UpperCAmelCase_			)
         except Exception:
                pass
                # dont copy tokenizer if cant
  
  
  if __name__ == "__main__":
     fire.Fire(convert_pl_to_hf)