
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__					(						lowerCamelCase     ,    lowerCamelCase						)  ->	Tuple:
				# Load checkpoint
				UpperCamelCase_:							List[Any]	=						torch.load(lowerCamelCase     ,    map_location="""cpu"""						)

				UpperCamelCase_:							Optional[int]	=						chkpt["""model"""]

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

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

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

				# Save pytorch-model
				UpperCamelCase_:							Dict	=						pytorch_dump_folder_path + """/""" + WEIGHTS_NAME
				UpperCamelCase_:							Optional[int]	=						pytorch_dump_folder_path + """/""" + CONFIG_NAME
				UpperCamelCase_:							Any	=						pytorch_dump_folder_path + """/""" + VOCAB_FILES_NAMES["""vocab_file"""]

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

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

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


if __name__ == "__main__":
							lowerCamelCase_						: Optional[Any]         =  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."""
							)
							lowerCamelCase_						: Tuple         =  parser.parse_args()
							convert_xlm_checkpoint_to_pytorch(args.xlm_checkpoint_path, args.pytorch_dump_folder_path)








def        A__					(						lowerCamelCase = 50						)  ->	int:
				UpperCamelCase_:							List[Any]	=						[[0] * 3 for _ in range(length + 1						)]

				for row_length in range(length + 1						):
								for tile_length in range(2     ,    5						):
												for tile_start in range(row_length - tile_length + 1						):
																different_colour_ways_number[row_length][tile_length - 2] += (
																    different_colour_ways_number[row_length - tile_start - tile_length][
																        tile_length - 2
																    ]
																    + 1
																)

				return sum(different_colour_ways_number[length]						)


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






