


import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM
def   _UpperCamelCase				(						lowerCAmelCase_   )						->Optional[int]:
   UpperCAmelCase							=     [
       """decoder.version""",
       """decoder.output_projection.weight""",
       """_float_tensor""",
       """decoder.embed_positions._float_tensor""",
   ]
   for k in ignore_keys:
      state_dict.pop(lowerCAmelCase_  ,						lowerCAmelCase_   )
def   _UpperCamelCase				(						lowerCAmelCase_   )						->List[Any]:
   UpperCAmelCase				,  UpperCAmelCase							=     emb.weight.shape
   UpperCAmelCase							=     nn.Linear(lowerCAmelCase_  ,						lowerCAmelCase_  ,						bias=lowerCAmelCase_   )
   UpperCAmelCase							=     emb.weight.data
   return lin_layer
def   _UpperCamelCase				(						lowerCAmelCase_   )						->Optional[Any]:
   UpperCAmelCase							=     torch.load(lowerCAmelCase_  ,						map_location="""cpu"""   )
   UpperCAmelCase							=     Namespace(**checkpoint["""cfg"""]["""model"""]   )
   UpperCAmelCase							=     checkpoint["""model"""]
   remove_ignore_keys_(lowerCAmelCase_   )
   UpperCAmelCase							=     state_dict["""decoder.embed_tokens.weight"""].shape[0]

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

   UpperCAmelCase							=     XGLMConfig(
       vocab_size=lowerCAmelCase_  ,						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							=     XGLMForCausalLM(lowerCAmelCase_   )
   UpperCAmelCase							=     model.load_state_dict(lowerCAmelCase_  ,						strict=lowerCAmelCase_   )
   print(lowerCAmelCase_   )
   UpperCAmelCase							=     make_linear_from_emb(model.model.embed_tokens   )

   return model


if __name__ == "__main__":
 __a     =			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.""")
 __a     =			parser.parse_args()
 __a     =			convert_fairseq_xglm_checkpoint_from_disk(args.fairseq_path)
 model.save_pretrained(args.pytorch_dump_folder_path)







from math import sqrt
def   _UpperCamelCase				(						lowerCAmelCase_ = 1_0_0_0_0_0_0   )						->int:
   UpperCAmelCase							=     0
   UpperCAmelCase							=     0
   UpperCAmelCase							=     42

   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(lowerCAmelCase_  ,						sum_shortest_sides // 2   )
                - max(1  ,						sum_shortest_sides - max_cuboid_size   )
                + 1
            )

   return max_cuboid_size


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



