[pytorch][codegen] migrate gen_variable_factories.py to the new data model (#47818)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47818
This is another relatively small codegen.
Ideally we should CppSignature.decl() to generate the c++ function declaration.
We didn't because it needs to add 'at::' to the types defined in ATen namespace.
E.g.:
- standard declaration:
```
Tensor eye(int64_t n, int64_t m, const TensorOptions & options={})
```
- expected:
```
at::Tensor eye(int64_t n, int64_t m, const at::TensorOptions & options = {})
```
Kept the hacky fully_qualified_type() method to keep compatibility with old codegen.
We could clean up by:
- Using these types in torch namespace - but this is a user facing header file,
not sure if it will cause problem;
- Update cpp.argument_type() method to take optional namespace argument;
Confirmed byte-for-byte compatible with the old codegen:
```
Run it before and after this PR:
.jenkins/pytorch/codegen-test.sh <baseline_output_dir>
.jenkins/pytorch/codegen-test.sh <test_output_dir>
Then run diff to compare the generated files:
diff -Naur <baseline_output_dir> <test_output_dir>
```
Test Plan: Imported from OSS
Reviewed By: bhosmer
Differential Revision: D24909478
Pulled By: ljk53
fbshipit-source-id: a0ceaa60cc765c526908fee39f151cd7ed5ec923