






'''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				)				->	List[str]:
							# Load checkpoint
							lowerCamelCase__ :     Tuple	  =	torch.load(UpperCamelCase    ,      map_location="""cpu"""				)

							lowerCamelCase__ :     Tuple	  =	chkpt["""model"""]

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

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

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

							# Save pytorch-model
							lowerCamelCase__ :     int	  =	pytorch_dump_folder_path + """/""" + WEIGHTS_NAME
							lowerCamelCase__ :     Tuple	  =	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(UpperCamelCase    ,      UpperCamelCase				)

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

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


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









'''simple docstring'''







from __future__ import annotations





def 			SCREAMING_SNAKE_CASE_	(UpperCamelCase    ,      UpperCamelCase				)				->	list[str]:
							if nth_term == "":
														return [""]
							lowerCamelCase__ :     str	  =	int(UpperCamelCase				)
							lowerCamelCase__ :     Union[str, Any]	  =	int(UpperCamelCase				)
							lowerCamelCase__ :     list[str]	  =	[]
							for temp in range(int(UpperCamelCase				)				):
														series.append(f'''1 / {pow(temp + 1    ,      int(UpperCamelCase				)				)}''' if series else """1"""				)
							return series


if __name__ == "__main__":
			import doctest

			doctest.testmod()

			_A     :      Optional[Any]   					=int(input('''Enter the last number (nth term) of the P-Series'''))
			_A     :      List[str]   					=int(input('''Enter the power for  P-Series'''))
			print('''Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p''')
			print(p_series(nth_term, power))

