Ho sorry I forgot to update the backward in my code sample above   Done now.
Any input that is not a Tensor that requires grad (either not a Tensor or a Tensor that does not require gradients) should have the backward return None for them.