Repository: pykeen/pykeen
Issue: ValueError: math domain error when using TransE or ComplEx to train YAGO3-10 dataset
Root cause: Validation Gap

### Describe the bug


My GPU is 2080Ti


error
```cmd
C:\anaconda3\envs\pt111\lib\site-packages\pykeen\nn\representation.py:369: UserWarning: Directly use Embedding.max_id instead of num_embeddings.
  warnings.warn(f"Directly use {self.__class__.__name__}.max_id instead of num_embeddings.")
C:\anaconda3\envs\pt111\lib\site-packages\pykeen\nn\representation.py:375: UserWarning: Directly use Embedding.shape instead of num_embeddings.
  warnings.warn(f"Directly use {self.__class__.__name__}.shape instead of num_embeddings.")
Training epochs on cuda:0: 100%|██████████| 1/1 [00:29<00:00, 29.14s/epoch, loss=0.0176, prev_loss=nan]
INFO:pykeen.evaluation.evaluator:Starting batch_size search for evaluation now...
C:\anaconda3\envs\pt111\lib\site-packages\pykeen\utils.py:591: RuntimeWarning: overflow encountered in long_scalars
  return sum(
C:\anaconda3\envs\pt111\lib\site-packages\pykeen\metrics\ranking.py:858: RuntimeWarning: divide by zero encountered in true_divide
  v = (n * h2 - h**2) / n**2
Traceback (most recent call last):
  File "D:/PythonCode/PatentValuation/kge2/pykeen2/t1.py", line 13, in <module>
    result = pipeline(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\pipeline\api.py", line 1314, in pipeline
    metric_results: MetricResults = _safe_evaluate(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\pipeline\api.py", line 1369, in _safe_evaluate
    metric_results: MetricResults = evaluator.evaluate(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\evaluator.py", line 172, in evaluate
    batch_size, slice_size = self.batch_and_slice(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\evaluator.py", line 249, in batch_and_slice
    batch_size, evaluated_once = self._param_size_search(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\evaluator.py", line 322, in _param_size_search
    evaluate(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\evaluator.py", line 701, in evaluate
    result = evaluator.finalize()
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\rank_based_evaluator.py", line 276, in finalize
    result = RankBasedMetricResults.from_ranks(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\rank_based_evaluator.py", line 99, in from_ranks
    data={
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\evaluation\rank_based_evaluator.py", line 100, in <dictcomp>
    (metric.key, target, rank_type): metric(ranks=ranks, num_candidates=num_candidates)
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\metrics\ranking.py", line 444, in __call__
    return self.adjust(
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\metrics\ranking.py", line 465, in adjust
    parameters = self.get_coefficients(num_candidates=num_candidates)
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\metrics\ranking.py", line 542, in get_coefficients
    std = self.base.std(num_candidates=num_candidates)
  File "C:\anaconda3\envs\pt111\lib\site-packages\pykeen\metrics\ranking.py", line 370, in std
    return math.sqrt(self.variance(num_candidates=num_candidates, num_samples=num_samples, **kwargs))
ValueError: math domain error
```

### How to reproduce

training code

```python
import pykeen
from pykeen.pipeline import pipeline
import matplotlib.pyplot as plt

print(pykeen.env())

result = pipeline(
    model='ComplEx',  # ComplEx  TransE
    dataset='YAGO3-10',  # Wikidata5M  FB15k-237  YAGO3-10
    training_kwargs=dict(
        num_epochs=1,
        use_tqdm_batch=False,
        batch_size=512,
    ),
    model_kwargs=dict(embedding_dim=100),
    random_seed=1235, 
)

path = './model_result/t1_result'
# Save model results
result.save_to_directory(path)
```

### Environment

| Key             | Value                    |
|-----------------|--------------------------|
| OS              | nt                       |
| Platform        | Windows                  |
| Release         | 10                       |
| Time            | Wed Apr 20 10:35:01 2022 |
| Python          | 3.8.13                   |
| PyKEEN          | 1.8.0                    |
| PyKEEN Hash     | UNHASHED                 |
| PyKEEN Branch   |                          |
| PyTorch         | 1.11.0+cu113             |
| CUDA Available? | true                     |
| CUDA Version    | 11.3                     |
| cuDNN Version   | 8200                     |

### Additional information

_No response_

The first message seems to be unrelated.
```
C:\anaconda3\envs\pt111\lib\site-packages\pykeen\utils.py:591: RuntimeWarning: overflow encountered in long_scalars
  return sum(
```

The error from
https://github.com/pykeen/pykeen/blob/12c3da815f03d17bca78d5255c7c4141625b9de7/src/pykeen/metrics/ranking.py#L857-L858
looks strange, since the range is only over strictly positive numbers. So maybe some overflow happens there.

@MGzhou can you also reproduce the error on a smaller dataset, e.g., `nations`?

> @MGzhou您是否还可以在较小的数据集上重现该错误，例如，`nations`？

This error does not occur in the small data set (nations,FB15k-237)（我在nations,FB15k-237这两个小数据集运行是正常的，没有抛出异常）

Okay, I think it might be caused by differences in the default numpy `dtype` for `np.arange`.

The number of entities in YAGO3-10, and thus also the maximum number of candidates for ranking, is `123143`, and thus its square `15164198449`, which is slightly larger than `2**31` since `math.log2(15164198449) ~33.81`. On my machine, `arange` uses `int64` for integer boundaries by default which can still hold the number `15164198449`. However, with `int32` this would not be the case. In any way, we could directly convert to a floating point type before squaring and thus avoid the issue, as we also did, e.g., here
https://github.com/pykeen/pykeen/blob/e43eddf1e9ec149e5318f480c57fd467a246ee13/src/pykeen/metrics/ranking.py#L1016-L1018

I push a fix soon.

thanks

should be fixed now - we'll make a patch release soon - afterwards you should be able to install the fixed version via
```console
pip install -U pykeen
```

okay，thanks