<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Test 1
Initialize embedding matrix and input
Step1:  propagate the input via the old method (embedded_dropout)
Step2:  propagate the input via the forward method in the new layer (EmbeddingDropout)
Step3:  Test 2
Initialize embedding and matrix
Step4:  get the input by propagating via the old method
Step5:  get the input by propagating input via the embedding layer
<ASSISTANT_TASK:>
Python Code:
embed = torch.nn.Embedding(10,3)
words = torch.autograd.Variable(torch.LongTensor([[1,2,4,5] ,[4,3,2,9]]))
Explanation: Test 1
Initialize embedding matrix and input
End of explanation
torch.manual_seed(88123)
dropout_out_old = embedded_dropout(embed, words, dropout=0.40)
dropout_out_old
Explanation: propagate the input via the old method (embedded_dropout)
End of explanation
torch.manual_seed(88123)
embed_dropout_layer = EmbeddingDropout(embed)
dropout_out_new = embed_dropout_layer(words, dropout=0.4)
dropout_out_new
print(np.testing.assert_array_equal(to_np(dropout_out_old),to_np(dropout_out_new)))
Explanation: propagate the input via the forward method in the new layer (EmbeddingDropout)
End of explanation
embed = torch.nn.Embedding(10,7)
words = torch.autograd.Variable(torch.LongTensor([[1,2,4,5,2,8] ,[4,3,2,9,7,6]]))
Explanation: Test 2
Initialize embedding and matrix
End of explanation
torch.manual_seed(7123)
dropout_out_old = embedded_dropout(embed, words, dropout=0.64)
dropout_out_old
Explanation: get the input by propagating via the old method
End of explanation
torch.manual_seed(7123)
embed_dropout_layer = EmbeddingDropout(embed)
dropout_out_new = embed_dropout_layer(words, dropout=0.64)
dropout_out_new
print(np.testing.assert_array_equal(to_np(dropout_out_old),to_np(dropout_out_new)))
Explanation: get the input by propagating input via the embedding layer
End of explanation
<END_TASK>