change torch.testing helper asserts to checks (#54780)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54780
- In #53152 we opted to use `tb=native`. Thus, regardless if we use `pytest` to run the tests `__tracebackhide__` is not honored. and additional layers of helper functions make the traceback harder to parse. To overcome this, we change the internal helpers to return `ok: bool, msg: Optional[str]` and only raise the error in the top level function. We do that already in the current implementation that we are trying to replace:
https://github.com/pytorch/pytorch/blob/36ce673f16269724f629f2a1897b8720ba6c8f18/torch/testing/__init__.py#L92-L93
https://github.com/pytorch/pytorch/blob/36ce673f16269724f629f2a1897b8720ba6c8f18/torch/testing/__init__.py#L112
Test Plan: Imported from OSS
Reviewed By: ngimel
Differential Revision: D27438849
Pulled By: mruberry
fbshipit-source-id: 3e7a33dabb45463c29e8b9736fad09efb523f18d