Fix custom function when non tensor argument precedes tensor argument (#71530)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/71530
Test Plan: Imported from OSS
Reviewed By: albanD
Differential Revision: D33695397
Pulled By: soulitzer
fbshipit-source-id: 49ccd062f73ccf69c47aca2552fde182d582be2a
(cherry picked from commit 68d502a01332701f80588735bb174df715fb3bcf)