

'''simple docstring'''

import argparse
import json

import numpy
import torch

from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()





def    A_  ( snake_case      ,       snake_case ):
  # Load checkpoint
  SCREAMING_SNAKE_CASE:Optional[int]						      =					torch.load(snake_case      ,       map_location="cpu" )

  SCREAMING_SNAKE_CASE:Union[str, Any]						      =					chkpt["model"]

  # We have the base model one level deeper than the original XLM repository
  SCREAMING_SNAKE_CASE:Optional[Any]						      =					{}
  for k, v in state_dict.items():
    if "pred_layer" in k:
      SCREAMING_SNAKE_CASE:Optional[int]						      =					v
    else:
      SCREAMING_SNAKE_CASE:Dict						      =					v

  SCREAMING_SNAKE_CASE:List[Any]						      =					chkpt["params"]
  SCREAMING_SNAKE_CASE:Dict						      =					{n: v for n, v in config.items() if not isinstance(snake_case      ,       (torch.FloatTensor, numpy.ndarray) )}

  SCREAMING_SNAKE_CASE:Tuple						      =					chkpt["dico_word2id"]
  SCREAMING_SNAKE_CASE:Any						      =					{s + "</w>" if s.find("@@" ) == -1 and i > 13 else s.replace("@@"      ,       "" ): i for s, i in vocab.items()}

  # Save pytorch-model
  SCREAMING_SNAKE_CASE:Union[str, Any]						      =					pytorch_dump_folder_path + "/" + WEIGHTS_NAME
  SCREAMING_SNAKE_CASE:List[str]						      =					pytorch_dump_folder_path + "/" + CONFIG_NAME
  SCREAMING_SNAKE_CASE:Any						      =					pytorch_dump_folder_path + "/" + VOCAB_FILES_NAMES["vocab_file"]

  print(F'''Save PyTorch model to {pytorch_weights_dump_path}''' )
  torch.save(snake_case      ,       snake_case )

  print(F'''Save configuration file to {pytorch_config_dump_path}''' )
  with open(snake_case      ,       "w"      ,       encoding="utf-8" ) as f:
    f.write(json.dumps(snake_case      ,       indent=2 ) + "\n" )

  print(F'''Save vocab file to {pytorch_config_dump_path}''' )
  with open(snake_case      ,       "w"      ,       encoding="utf-8" ) as f:
    f.write(json.dumps(snake_case      ,       indent=2 ) + "\n" )


if __name__ == "__main__":
    A_       						=							argparse.ArgumentParser()
    # Required parameters
    parser.add_argument(
        "--xlm_checkpoint_path", default=None, type=str, required=True, help="Path the official PyTorch dump."
    )
    parser.add_argument(
        "--pytorch_dump_folder_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
    )
    A_       						=							parser.parse_args()
    convert_xlm_checkpoint_to_pytorch(args.xlm_checkpoint_path, args.pytorch_dump_folder_path)









'''simple docstring'''

def    A_  ( snake_case ):
  SCREAMING_SNAKE_CASE:Dict						      =					(1 + 24 * n) ** 0.5
  return ((1 + root) / 6) % 1 == 0





def    A_  ( snake_case = 5000 ):
  SCREAMING_SNAKE_CASE:int						      =					[(i * (3 * i - 1)) // 2 for i in range(1      ,       snake_case )]
  for i, pentagonal_i in enumerate(snake_case ):
    for j in range(snake_case      ,       len(snake_case ) ):
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_nums[j]
      SCREAMING_SNAKE_CASE:Any						      =					pentagonal_i + pentagonal_j
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_j - pentagonal_i
      if is_pentagonal(snake_case ) and is_pentagonal(snake_case ):
        return b

  return -1


if __name__ == "__main__":
    print(f'''{solution() = }''')






