def begin_update(self, x_data, h_0=None, drop=<NUM_LIT:0.0>):
x_var = torch.autograd.Variable(xp2torch(x_data), requires_grad=True)<EOL>out, h_n = self._model(x_var, h_0)<EOL>def backward_pytorch_rnn(d_data, sgd=None):<EOL><INDENT>dy_data, _ = d_data<EOL>dout = xp2torch(dy_data)<EOL>torch.autograd.backward((out,), grad_tensors=(dout,))<EOL>if sgd is not None:<EOL><INDENT>if self._optimizer is None:<EOL><INDENT>self._optimizer = self._create_optimizer(sgd)<EOL><DEDENT>self._optimizer.step()<EOL>self._optimizer.zero_grad()<EOL><DEDENT>return torch2xp(x_var.grad)<EOL><DEDENT>return (torch2xp(out), h_n), backward_pytorch_rnn<EOL>
Return the output of the wrapped PyTorch model for the given input,
        along with a callback to handle the backward pass.