


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 		lowercase_(  SCREAMING_SNAKE_CASE_      ,						SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  lowerCamelCase :					Optional[Any]    =				torch.load(SCREAMING_SNAKE_CASE_      ,						map_location="cpu"	)

  lowerCamelCase :					Any    =				chkpt["model"]

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

  lowerCamelCase :					Union[str, Any]    =				chkpt["params"]
  lowerCamelCase :					int    =				{n: v for n, v in config.items() if not isinstance(SCREAMING_SNAKE_CASE_      ,						(torch.FloatTensor, numpy.ndarray)	)}

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

  # Save pytorch-model
  lowerCamelCase :					List[str]    =				pytorch_dump_folder_path + "/" + WEIGHTS_NAME
  lowerCamelCase :					Optional[int]    =				pytorch_dump_folder_path + "/" + CONFIG_NAME
  lowerCamelCase :					Optional[int]    =				pytorch_dump_folder_path + "/" + VOCAB_FILES_NAMES["vocab_file"]

  print(f"""Save PyTorch model to {pytorch_weights_dump_path}"""	)
  torch.save(SCREAMING_SNAKE_CASE_      ,						SCREAMING_SNAKE_CASE_	)

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

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


if __name__ == "__main__":
   _snake_case             =     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.'''
   )
   _snake_case             =     parser.parse_args()
   convert_xlm_checkpoint_to_pytorch(args.xlm_checkpoint_path, args.pytorch_dump_folder_path)







def 		lowercase_(  SCREAMING_SNAKE_CASE_ = 4000000	):


  '''simple docstring'''

  lowerCamelCase :					Any    =				[0, 1]
  lowerCamelCase :					Union[str, Any]    =				0
  while fib[i] <= n:
    fib.append(fib[i] + fib[i + 1]	)
    if fib[i + 2] > n:
      break
    i += 1
  lowerCamelCase :					Union[str, Any]    =				0
  for j in range(len(SCREAMING_SNAKE_CASE_	) - 1	):
    if fib[j] % 2 == 0:
      total += fib[j]

  return total


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



