Repository: pykeen/pykeen (language: python)

Issue:
TypeError: DoubleMarginLoss.__init__() got an unexpected keyword argument 'margin_positive'
### Describe the bug

This error occurs when using the hpo pipeline with the DoubleMarginLoss. I did not use a parameter called margin_positive. Unfortunately, I don't know what values the other components were because I was trying out a random search and did not log in case of failure. I thought it might be good to know regardless. In the documentation for the DoubleMarginLoss, the parameter is called positive_margin, not margin_positive. The traceback is the following:
```python
hpo_result = hpo_pipeline(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/hpo/hpo.py", line 868, in hpo_pipeline
    study.optimize(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/study.py", line 425, in optimize
    _optimize(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 66, in _optimize
    _optimize_sequential(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 163, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 251, in _run_trial
    raise func_err
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/optuna/study/_optimize.py", line 200, in _run_trial
    value_or_values = func(trial)
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/hpo/hpo.py", line 259, in __call__
    result = pipeline(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/pipeline/api.py", line 1509, in pipeline
    model_instance = _handle_model(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/pipeline/api.py", line 979, in _handle_model
    model_instance, model_kwargs = _build_model_helper(
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/pykeen/pipeline/api.py", line 839, in _build_model_helper
    model_kwargs["loss"] = loss_resolver.make(loss, loss_kwargs)
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/class_resolver/api.py", line 210, in make
    raise e
  File "/home/anaconda3/envs/pykeen/lib/python3.10/site-packages/class_resolver/api.py", line 204, in make
    return cls(**(pos_kwargs or {}), **kwargs)  # type: ignore
TypeError: DoubleMarginLoss.__init__() got an unexpected keyword argument 'margin_positive'
```

### How to reproduce

Use `hpo_pipeline` with the `DoubleMarginLoss`

### Environment

| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Linux                    |
| Release         | 6.2.0-33-generic         |
| Time            | Mon Oct  2 13:27:42 2023 |
| Python          | 3.10.9                   |
| PyKEEN          | 1.10.0                   |
| PyKEEN Hash     | UNHASHED                 |
| PyKEEN Branch   |                          |
| PyTorch         | 1.13.1+cu117             |
| CUDA Available? | true                     |
| CUDA Version    | 11.7                     |
| cuDNN Version   | 8500                     |


### Additional information

_No response_

### Issue Template Checks

- [X] This is not a feature request (use a different issue template if it is)
- [X] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [X] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed


Discussion / hints:
Here's the line that needs to get fixed (rename `margin_positive` to `positive_margin`):

https://github.com/pykeen/pykeen/blob/d5b409f0aa265bae278656e21526b008c780a2e7/src/pykeen/losses.py#L689

More generally, we should test that all keys in `hpo_default` dictionaries correspond to keyword arguments in the class's `__init__`.

Fix patch:
diff --git a/src/pykeen/losses.py b/src/pykeen/losses.py
index 52601be38a..3143947b40 100644
--- a/src/pykeen/losses.py
+++ b/src/pykeen/losses.py
@@ -686,7 +686,7 @@ class DoubleMarginLoss(PointwiseLoss):
     """
 
     hpo_default: ClassVar[Mapping[str, Any]] = dict(
-        margin_positive=dict(type=float, low=-1, high=1),
+        positive_margin=dict(type=float, low=-1, high=1),
         offset=dict(type=float, low=0, high=1),
         positive_negative_balance=dict(type=float, low=1.0e-03, high=1.0 - 1.0e-03),
         margin_activation=dict(


Test patch:
diff --git a/tests/cases.py b/tests/cases.py
index db31e85cc8..73bd14229d 100644
--- a/tests/cases.py
+++ b/tests/cases.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 """Test cases for PyKEEN."""
-
+import inspect
 import logging
 import os
 import pathlib
@@ -351,6 +351,12 @@ def test_optimization_direction_slcwa(self):
         # negative scores decreased compared to positive ones
         assert (negative_scores < positive_scores.unsqueeze(dim=1) - 1.0e-06).all()
 
+    def test_hpo_defaults(self):
+        """Test hpo defaults."""
+        signature = inspect.signature(self.cls.__init__)
+        invalid_keys = set(self.cls.hpo_default.keys()).difference(signature.parameters)
+        assert not invalid_keys
+
 
 class PointwiseLossTestCase(LossTestCase):
     """Base unit test for label-based losses."""