complex: register c10::complex with py::cast (#89680)
Fixes #77134
TODO:
* [x] Add test (tested locally with script below) (Are there similar tests in the test-suite?)
```c++
#include <torch/torch.h>
#include <torch/csrc/utils/pybind.h>
#include <iostream>
#include <vector>
#include <pybind11/pybind11.h>
#include <pybind11/embed.h>
#include <cassert>
namespace py = pybind11;
int main() {
py::scoped_interpreter guard{}; // start the interpreter
auto casted_cdouble = py::cast(c10::complex<double>(1.0, 2.0));
assert(
(c10::complex<double>(1.0, 2.0) ==
py::cast<c10::complex<double>>(casted_cdouble)));
auto casted_cfloat = py::cast(c10::complex<float>(1.0, 2.0));
assert(
(c10::complex<double>(1.0, 2.0) ==
py::cast<c10::complex<double>>(casted_cfloat)));
auto casted_chalf = py::cast(c10::complex<at::Half>(1.0, 2.0));
assert(
(c10::complex<double>(1.0, 2.0) ==
py::cast<c10::complex<double>>(casted_chalf)));
}
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/89680
Approved by: https://github.com/ezyang