Prevent custom Functions from creating non differentiable type that requires grad (#38326)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/38326
Test Plan: Imported from OSS
Differential Revision: D21668740
Pulled By: albanD
fbshipit-source-id: f452f65e76003492055311523a652937b1300183