To implement gradient for Pytorch (#54617)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/56129
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54617
Reviewed By: anjali411
Differential Revision: D28057452
Pulled By: iramazanli
fbshipit-source-id: 9bd86679282d34f5e5393e6447121586517eb4f0