def begin_update(self, x_data, drop=<NUM_LIT:0.0>):
x_var = torch.autograd.Variable(xp2torch(x_data), requires_grad=True)<EOL>y_var = self._model(x_var)<EOL>def backward_pytorch(dy_data, sgd=None):<EOL><INDENT>dy_var = xp2torch(dy_data)<EOL>torch.autograd.backward((y_var,), grad_tensors=(dy_var,))<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(y_var), backward_pytorch<EOL>
Return the output of the wrapped PyTorch model for the given input,
        along with a callback to handle the backward pass.