[Testing] Turn instantiate_parametrized_tests into a decorator (#78228)
The change
1. Returns the input param in `instantiate_parametrized_tests` so that we can use it as a decorator.
Instead of
```python
instantiate_parametrized_tests(SomeTestClass)
```
we can now do
```python
@instantiate_parametrized_tests
class SomeTestClass:
...
```
2. Strips spaces around parameters in `parametrize`.
Both
```python
@parametrize("x,y", [(1, 'foo'), (2, 'bar'), (3, 'baz')])
def test_bar(self, x, y):
...
```
and
```python
@parametrize("x, y", [(1, 'foo'), (2, 'bar'), (3, 'baz')])
def test_bar(self, x, y):
...
```
(or
```python
@parametrize("x, y", [(1, 'foo'), (2, 'bar'), (3, 'baz')])
````
, for that matter), are now parsed to the correct argument names.
3. Decorates test wrappers with `functools.wraps` to preserve the test method names (previously the names become "wrapper_xxx", which prevents the parameterized tests from getting the correct names.)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78228
Approved by: https://github.com/garymm, https://github.com/seemethere