Calling backward() with indexing in the function

see this answer in this post