



'''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        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase      ):



				"""simple docstring"""





				lowerCAmelCase__			:  Union[str, Any]											= torch.load(snake_case__							,   map_location="""cpu"""      )

				lowerCAmelCase__			:  Optional[Any]											= chkpt['model']

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

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

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

				# Save pytorch-model
				lowerCAmelCase__			:  Tuple											= pytorch_dump_folder_path + '/' + WEIGHTS_NAME
				lowerCAmelCase__			:  List[str]											= pytorch_dump_folder_path + '/' + CONFIG_NAME
				lowerCAmelCase__			:  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__":
	_lowerCAmelCase										=     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										=     parser.parse_args()
	convert_xlm_checkpoint_to_pytorch(args.xlm_checkpoint_path, args.pytorch_dump_folder_path)







'''simple docstring'''





def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase = 1000      ):



    """simple docstring"""





    lowerCAmelCase__			:  Union[str, Any]											= -1
    lowerCAmelCase__			:  Optional[Any]											= 0
    for a in range(1							,   n // 3      ):
        # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c
        lowerCAmelCase__			:  Optional[Any]											= (n * n - 2 * a * n) // (2 * n - 2 * a)
        lowerCAmelCase__			:  Tuple											= n - a - b
        if c * c == (a * a + b * b):
            lowerCAmelCase__			:  int											= a * b * c
            if candidate >= product:
                lowerCAmelCase__			:  Any											= candidate
    return product


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


