It’s also unclear whether what you’re writing needs to be a Function. If you want the autograd library to automatically compute the backwards pass for your operation, and you can represent the operation as a combination of existing autograd-enabled functions (as it looks like you’ve done in forward), you should just define a Python function or a Module.
If you do need to write a new Function subclass, that means you aren’t able to represent the operation as a combination of existing functions with known derivatives, and you have to implement the backward pass yourself (you can’t just call .backward()). The computations inside the forward and backward methods of a Function subclass take place on Tensor objects, not Variables.