You can use the ctx to save everything you want exept for input or output that should only be saved with save_for_backward (to avoid bugs).
The backward definition works with Variable by default. If your backward implementation is not differentiable (meaning you can’t do backward of backward), then you can use the @once_differentiable (can be imported torch.autograd.function) decorator on top of the @static_method for your backward and it will receive directly Tensor and will raise a proper error if you try to differentiate it.