CustomFunctionBackward is created to represent the state of your Function. An instance of it is created during the .apply() call and is passed as the ctx (though the fact that the context is of this class is not important).
The relevant code is the FunctionMeta in torch/autograd/function.py and THPFunction_apply() in torch/csrc/autograd/python_function.cpp.