

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 							__SCREAMING_SNAKE_CASE     (   a__    :   Any			,a__    :   Optional[Any]       )					->				Union[str, Any]:
	# Load checkpoint
	__A :			Union[str, Any]		    =			torch.load(a__			,map_location="""cpu"""       )

	__A :			Optional[Any]		    =			chkpt["""model"""]

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

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

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

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

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

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

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


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








from math import sqrt
def 							__SCREAMING_SNAKE_CASE     (   a__    :   int = 1000000       )					->				int:
	__A :			int		    =			0
	__A :			int		    =			0
	__A :			int

	while num_cuboids <= limit:
		max_cuboid_size += 1
		for sum_shortest_sides in range(2			,2 * max_cuboid_size + 1       ):
			if sqrt(sum_shortest_sides**2 + max_cuboid_size**2       ).is_integer():
				num_cuboids += (
				    min(a__			,sum_shortest_sides // 2       )
				    - max(1			,sum_shortest_sides - max_cuboid_size       )
				    + 1
				)

	return max_cuboid_size


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





