




import cmath
import math





def __UpperCamelCase			(       _A ,  _A ,  _A ,  _A  ):
						lowerCAmelCase_      			=  math.radians(_A  )
						lowerCAmelCase_      			=  math.radians(_A  )

						# Convert voltage and current to rectangular form
						lowerCAmelCase_      			=  cmath.rect(_A ,  _A  )
						lowerCAmelCase_      			=  cmath.rect(_A ,  _A  )

						# Calculate apparent power
						return voltage_rect * current_rect


if __name__ == "__main__":
						import doctest

						doctest.testmod()










import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM





def __UpperCamelCase			(       _A  ):
						lowerCAmelCase_      			=  [
						    '''decoder.version''',
						    '''decoder.output_projection.weight''',
						    '''_float_tensor''',
						    '''decoder.embed_positions._float_tensor''',
						]
						for k in ignore_keys:
												state_dict.pop(_A ,  _A  )





def __UpperCamelCase			(       _A  ):
						lowerCAmelCase_			,					lowerCAmelCase_      			=  emb.weight.shape
						lowerCAmelCase_      			=  nn.Linear(_A ,  _A ,  bias=_A  )
						lowerCAmelCase_      			=  emb.weight.data
						return lin_layer





def __UpperCamelCase			(       _A  ):
						lowerCAmelCase_      			=  torch.load(_A ,  map_location='''cpu'''  )
						lowerCAmelCase_      			=  Namespace(**checkpoint['''cfg''']['''model''']  )
						lowerCAmelCase_      			=  checkpoint['''model''']
						remove_ignore_keys_(_A  )
						lowerCAmelCase_      			=  state_dict['''decoder.embed_tokens.weight'''].shape[0]

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

						lowerCAmelCase_      			=  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 ,  )

						lowerCAmelCase_      			=  XGLMForCausalLM(_A  )
						lowerCAmelCase_      			=  model.load_state_dict(_A ,  strict=_A  )
						print(_A  )
						lowerCAmelCase_      			=  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)




