






"""simple docstring"""
import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM

def        snake_case   (     A__		):
			UpperCAmelCase_  :				List[str]      =      [
			    "decoder.version",
			    "decoder.output_projection.weight",
			    "_float_tensor",
			    "decoder.embed_positions._float_tensor",
			]
			for k in ignore_keys:
						state_dict.pop(A__			,A__		)

def        snake_case   (     A__		):
			UpperCAmelCase_  ,			UpperCAmelCase_  :				Union[str, Any]      =      emb.weight.shape
			UpperCAmelCase_  :				Optional[int]      =      nn.Linear(A__			,A__			,bias=A__		)
			UpperCAmelCase_  :				Optional[int]      =      emb.weight.data
			return lin_layer

def        snake_case   (     A__		):
			UpperCAmelCase_  :				Optional[int]      =      torch.load(A__			,map_location="cpu"		)
			UpperCAmelCase_  :				Tuple      =      Namespace(**checkpoint["cfg"]["model"]		)
			UpperCAmelCase_  :				str      =      checkpoint["model"]
			remove_ignore_keys_(A__		)
			UpperCAmelCase_  :				Dict      =      state_dict["decoder.embed_tokens.weight"].shape[0]

			UpperCAmelCase_  :				Tuple      =      {key.replace("decoder"			,"model"		): val for key, val in state_dict.items()}

			UpperCAmelCase_  :				Tuple      =      XGLMConfig(
			    vocab_size=A__			,max_position_embeddings=args.max_target_positions			,num_layers=args.decoder_layers			,attention_heads=args.decoder_attention_heads			,ffn_dim=args.decoder_ffn_embed_dim			,d_model=args.decoder_embed_dim			,layerdrop=args.decoder_layerdrop			,dropout=args.dropout			,attention_dropout=args.attention_dropout			,activation_dropout=args.activation_dropout			,activation_function="gelu"			,scale_embedding=not args.no_scale_embedding			,tie_word_embeddings=args.share_decoder_input_output_embed			,)

			UpperCAmelCase_  :				List[Any]      =      XGLMForCausalLM(A__		)
			UpperCAmelCase_  :				Tuple      =      model.load_state_dict(A__			,strict=A__		)
			print(A__		)
			UpperCAmelCase_  :				Tuple      =      make_linear_from_emb(model.model.embed_tokens		)

			return model


if __name__ == "__main__":
			lowerCamelCase_       			=   argparse.ArgumentParser()
			# Required parameters
			parser.add_argument('''fairseq_path''', type=str, help='''path to a model.pt on local filesystem.''')
			parser.add_argument('''pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
			lowerCamelCase_       			=   parser.parse_args()
			lowerCamelCase_       			=   convert_fairseq_xglm_checkpoint_from_disk(args.fairseq_path)
			model.save_pretrained(args.pytorch_dump_folder_path)











"""simple docstring"""
from __future__ import annotations

import math

def        snake_case   (     A__		):

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5			,int(math.sqrt(A__		) + 1		)			,6		):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True


lowerCamelCase_       			=   [num for num in range(3, 10_0001, 2) if not is_prime(num)]

def        snake_case   (     A__		):
			if not isinstance(A__			,A__		):
						raise ValueError("n must be an integer"		)
			if n <= 0:
						raise ValueError("n must be >= 0"		)

			UpperCAmelCase_  :				List[str]      =      []
			for num in range(len(A__		)		):
						UpperCAmelCase_  :				Dict      =      0
						while 2 * i * i <= odd_composites[num]:
									UpperCAmelCase_  :				List[str]      =      odd_composites[num] - 2 * i * i
									if is_prime(A__		):
												break
									i += 1
						else:
									list_nums.append(odd_composites[num]		)
									if len(A__		) == n:
												return list_nums

			return []

def        snake_case   (     ):
			return compute_nums(1		)[0]


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



