Refactor TensorWithTFOverrideVariable (#109556)
Summary:
This is purely a refactor that preserves the existing behavior and tests.
The main contributions of the PR are to refactor the dispatch of `__torch_function__` to enable calling it with TF override objects in any argument position and matching the eager dispatch behavior.
This will allow for the following in upcoming PRs:
1) have TensorWithTFOverrideVariable inherit from TensorVariable
2) enable tracing through the base `__torch_function__` implementation.
Note: this depends on https://github.com/pytorch/pytorch/pull/109542
towards tracing for https://github.com/pytorch/pytorch/issues/93723
X-link: https://github.com/pytorch/pytorch/pull/109556
Approved by: https://github.com/jansel, https://github.com/ezyang
Reviewed By: izaitsevfb
Differential Revision: D50511363
Pulled By: mlazos
fbshipit-source-id: ac5992b093cf8387d9aaf0d85fb7f11d2fb4ed57