Problem in Backpropagation [Solved]

I have a custom rnn class, where i have defined the weights in a dictionary in the constructor. In forward function i have written custom operations . Also wrote a separate function to calculate loss and update the parameters. For first pass everything is working fine but in second pass few of the variables (Hidden_memory and output of forward pass which is passed to next time step) becoming volatile and giving error “element 0 of variables tuple is volatile” .

Input and output is a time series data
x=torch.from_numpy(x)
x=Variable(x,requires_grad=True)
y=torch.from_numpy(y)
y=Variable(y)

the code of rnn class and error i have attached.Thanks in advance