Repository: pykeen/pykeen
Issue: Update models using complex numbers
Root cause: External Dependency Breakage

As of the PyTorch 1.6 [release](https://pypi.org/project/torch/1.6.0/) on July 28th, 2020, there is a native type for tensors of complex numbers (see: https://pytorch.org/docs/stable/complex_numbers.html)

From @mberr: Referencing the 1.7.1 release tracker here, in case they mention something about it: https://github.com/pytorch/pytorch/issues/47622

It would be interesting to test updated implementations of models using complex tensors such as RotatE and ComplEx to see if we can make them more elegant using this new trick. #292 is a good solution, but still not native. #134 presents a solution where the tensors themselves inside the Embedding are assigned the complex dtype like in:

```python
...
# initialize weight outside of torch.nn.Embedding to sneak in the dtype definitiion
_weight = torch.empty((num_embeddings, embedding_dim), dtype=dtype)

self._embeddings = torch.nn.Embedding(
    num_embeddings=num_embeddings,
    embedding_dim=embedding_dim,
    _weight=_weight,
)
...
```

Then, the math in ComplEx can be updated like in:

```python
# old
(h_re, h_im), (r_re, r_im), (t_re, t_im) = [split_complex(x=x) for x in (h, r, t)]

# new
h_re, h_im = h.real, h.imag
r_re, r_im = r.real, r.imag
t_re, t_im = t.real, t.imag
````

However, this update is blocked by a major issue - the `torch.nn.functional.embedding` function does not currently support automatic differentiation on complex tensors.

```python-traceback
Traceback (most recent call last):
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/Users/cthoyt/dev/pykeen/tests/test_models.py", line 439, in test_score_r_with_score_hrt_equality
    raise e
  File "/Users/cthoyt/dev/pykeen/tests/test_models.py", line 431, in test_score_r_with_score_hrt_equality
    scores_r = self.model.score_r(batch)
  File "/Users/cthoyt/dev/pykeen/src/pykeen/models/base.py", line 993, in score_r
    expanded_scores = self.score_hrt(hrt_batch=hrt_batch)
  File "/Users/cthoyt/dev/pykeen/src/pykeen/models/unimodal/complex.py", line 151, in score_hrt
    h = self.entity_embeddings(indices=hrt_batch[:, 0])
  File "/Users/cthoyt/.virtualenvs/pykeen/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/Users/cthoyt/dev/pykeen/src/pykeen/nn/emb.py", line 177, in forward
    x = self._embeddings(indices)
  File "/Users/cthoyt/.virtualenvs/pykeen/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/Users/cthoyt/.virtualenvs/pykeen/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 124, in forward
    return F.embedding(
  File "/Users/cthoyt/.virtualenvs/pykeen/lib/python3.8/site-packages/torch/nn/functional.py", line 1852, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: embedding does not support automatic differentiation for outputs with complex dtype.
```