Thank you for commenting.
I try to implement a function for forward/backward.
I met following error message.
RuntimeError: Function TestBackward returned an invalid gradient at index 0 - expected shape [1000] but got [1, 1000]

Then I investigate it and found it seems InputBuffer in FunctionTask is not expected shape. (specifically metadata.shape() and grads[i].sizes() inconsistency.)
Is there any tips to fix InputBuffer tensor size?