Fix input_buffer check if inplace update is valid (#59817)
Summary:
Fixes an issue introduced in https://github.com/pytorch/pytorch/issues/17182
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59817
Reviewed By: bdhirsh
Differential Revision: D29040738
Pulled By: albanD
fbshipit-source-id: 67fd4e9fa0dadf507ddd954d20e119d8781c4de0