This works! Thank you.
Although this solution works, the documentation said that we must use ctx.save_for_backward() to save tensors for backward calculation. So, is there any guidance on when and why we may save a tensor directly on ctx or using  ctx.save_for_backward()? I don’t clearly understand the need for ctx.save_for_backward() if we can simply save tensors directly to ctx.