




import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM





def 				A__ (snake_case   :		List[str]				)     ->						Optional[int]:
					__UpperCamelCase					:	Tuple             =      [
					    """decoder.version""",
					    """decoder.output_projection.weight""",
					    """_float_tensor""",
					    """decoder.embed_positions._float_tensor""",
					]
					for k in ignore_keys:
										state_dict.pop(snake_case		,	snake_case				)





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





def 				A__ (snake_case   :		Union[str, Any]				)     ->						Union[str, Any]:
					__UpperCamelCase					:	List[str]             =      torch.load(snake_case		,	map_location="""cpu"""				)
					__UpperCamelCase					:	Optional[int]             =      Namespace(**checkpoint["""cfg"""]["""model"""]				)
					__UpperCamelCase					:	Union[str, Any]             =      checkpoint["""model"""]
					remove_ignore_keys_(snake_case				)
					__UpperCamelCase					:	Optional[int]             =      state_dict["""decoder.embed_tokens.weight"""].shape[0]

					__UpperCamelCase					:	Optional[int]             =      {key.replace("""decoder"""		,	"""model"""				): val for key, val in state_dict.items()}

					__UpperCamelCase					:	List[Any]             =      XGLMConfig(
					    vocab_size=snake_case		,	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(snake_case				)
					__UpperCamelCase					:	str             =      model.load_state_dict(snake_case		,	strict=snake_case				)
					print(snake_case				)
					__UpperCamelCase					:	Tuple             =      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)












import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.layers import LSTM, Dense
from tensorflow.keras.models import Sequential

if __name__ == "__main__":
	a__		     =     pd.read_csv('''sample_data.csv''', header=None)
	a__		     =     df.shape[:1][0]
	# If you're using some other dataset input the target column
	a__		     =     df.iloc[:, 1:2]
	a__		     =     actual_data.values.reshape(len_data, 1)
	a__		     =     MinMaxScaler().fit_transform(actual_data)
	a__		     =     10
	a__		     =     5
	a__		     =     20
	a__		     =     len_data - periods * look_back
	a__		     =     actual_data[:division]
	a__		     =     actual_data[division - look_back :]
	a__     ,							a__		     =     [], []
	a__     ,							a__		     =     [], []

	for i in range(0, len(train_data) - forward_days - look_back + 1):
		train_x.append(train_data[i : i + look_back])
		train_y.append(train_data[i + look_back : i + look_back + forward_days])
	for i in range(0, len(test_data) - forward_days - look_back + 1):
		test_x.append(test_data[i : i + look_back])
		test_y.append(test_data[i + look_back : i + look_back + forward_days])
	a__		     =     np.array(train_x)
	a__		     =     np.array(test_x)
	a__		     =     np.array([list(i.ravel()) for i in train_y])
	a__		     =     np.array([list(i.ravel()) for i in test_y])

	a__		     =     Sequential()
	model.add(LSTM(128, input_shape=(look_back, 1), return_sequences=True))
	model.add(LSTM(64, input_shape=(128, 1)))
	model.add(Dense(forward_days))
	model.compile(loss='''mean_squared_error''', optimizer='''adam''')
	a__		     =     model.fit(
	    x_train, y_train, epochs=150, verbose=1, shuffle=True, batch_size=4
	)
	a__		     =     model.predict(x_test)






