Use onnx function only in tracing mode (#5468)
Use onnx function only in tracing mode (#5468)

* Use onnx function only in tracing mode

* Add missing import

* Address review comments

* Fix type annotation

* Ignore return type error

* Remove unused import

* Add fake cast

* Fix mypy error

* Fix mypy error

* Update torchvision/models/detection/_utils.py

Co-authored-by: Shubham Bhokare <839ee609688ee57af2360925d7cb4d11f5ea8038@users.noreply.github.com>

* _fake_cast_onnx approach

Co-authored-by: Vasilis Vryniotis <d748cd3f763058dcf20e5489b9bc2373b78db68c@users.noreply.github.com>
Co-authored-by: Shubham Bhokare <839ee609688ee57af2360925d7cb4d11f5ea8038@users.noreply.github.com>
pytorch/vision,pytorch/vision,pytorch/vision,pytorch/vision,pytorch/vision,pytorch/vision