Allow implementing either backward or vjp for Function (#63434)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63434
Test Plan: Imported from OSS
Reviewed By: ejguan
Differential Revision: D30431968
Pulled By: albanD
fbshipit-source-id: 0bb88664283486a9fd3364e6c3d79442a44625c2