.
variable hooks but instead uses a custom autograd Function, modifying the computational graph. As the official implementation contains many details, we focus on a simplified one instead: class Checkpoint(torch.autograd.Function): @staticmethod def forward(ctx, run_function, input): ctx.run_function