Repository: pykeen/pykeen
Issue: HPO pipeline for the MultiModal KGE models
Root cause: Unimplemented Feature Gap

**Describe the bug**
[A clear and concise description of what the bug is.]

Hi,
I am trying to use the HPO pipeline for the MultiModal KGE models (DistMultLiteral and ComplExLiteral) with my own data. However, it seems currently the pipeline doesn't support such models. It raises errors.

**To Reproduce**
A very simple example just to show one of the errors:

```python
from pykeen.hpo import hpo_pipeline
from pykeen.datasets.nations import NationsLiteral
result = hpo_pipeline(
    n_trials=3,
    dataset=NationsLiteral, 
    model='DistMultLiteral',
)
print(result)
```
See error:
...
--> 839         _original_init(self, *args, **kwargs)
    840         self.reset_parameters_()
    841 

TypeError: __init__() got an unexpected keyword argument 'regularizer'

 It would be great if the bugs are fixed so that we could use the HPO for MultiModals as well. Thank you.  

@GenetAsefa thanks for the bug report, I'll see if I can take care of this for you. I think there's a lot to be desired for working with these kinds of models - your mileage may vary. We also have #245 where we will be updating the implementation to be a bit more slick

@cthoyt, thank you for the quick response. Yes, you are right, there is a lot that could be considered when it comes to such models and #245 would definitely provide more flexibility. However, for now, it would be also nice to be able to use both pipelines (pykeen.pipeline and pykeen.HPO_pipeline) for multimodal KGEs as they are used for unimodals.   I am conducting experiments with my own pre-stratified data through CLI. I haven't really gone beyond the pipelines as they are enough for what I am doing and everything went smoothly so far with the unimodals and I want to do the same with DistMultLiteral and ComplExLiteral. Thanks again and looking forward. 

@GenetAsefa thanks for the inspiration, I've added a unit test to check for your scenario and implemented code to solve the issue (see PR link above). In fact, it motivated me to do a bit more cleanup that I had conceived before but never implemented, which will be much better with new-style PyKEEN models where regularization is even more extensible

@cthoyt yes, that particular issue has been resolved with the changes you have made, thank you. There is one more issue with the HPO (I don't know if I need to open a new issue) I am describing it here. 

while running the following command:
```
!pykeen experiments optimize -d /content/drive/MyDrive/NationsLiteral/0000_user_data_distmult/  /content/drive/MyDrive/HPO_Configurations/hpo_config.json 
```
where the content of the hpo_config.json file is :

```json
{
  "type": "hpo",
  "metadata": {
    "title": "HPO over NationsLiteral with LCWA"
  },
  "pipeline": {
    "stopper": "early",
    "stopper_kwargs": {
      "frequency": 10,
      "patience": 2,
      "metric": "mean_reciprocal_rank",
      "relative_delta": 0.002
    },
    "dataset": "NationsLiteral",
    "dataset_kwargs": {
      "create_inverse_triples": false
    },
    "model": "DistMultLiteral",
    "model_kwargs": {
      "entity_initializer": "xavier_uniform",
      "relation_initializer": "xavier_uniform",
      "entity_constrainer": "normalize"
    },
    "model_kwargs_ranges": {
      "embedding_dim": {
        "type": "int",
        "low": 6,
        "high": 8,
        "scale": "power_two"
      }
    },
    "loss": "CrossEntropyLoss",
    "regularizer": "LPRegularizer",
    "regularizer_kwargs_ranges": {
      "p": {
        "type": "int",
        "low": 1,
        "high": 2,
        "q": 1
      },
      "weight": {
        "type": "float",
        "low": 0.01,
        "high": 1.0,
        "scale": "log"
      }
    },
    "optimizer": "adam",
    "optimizer_kwargs": {
      "weight_decay": 0.0
    },
    "optimizer_kwargs_ranges": {
      "lr": {
        "type": "float",
        "low": 0.001,
        "high": 0.1,
        "sclae": "log"
      }
    },
    "training_loop": "LCWA",
    "training_kwargs": {
      "num_epochs": 100
    },
    "training_kwargs_ranges": {
      "batch_size": {
        "type": "int",
        "low": 7,
        "high": 9,
        "scale": "power_two"
      },
      "label_smoothing": {
        "type": "float",
        "low": 0.001,
       "high": 0.1,
        "sclae": "log"
      }
    },
    "evaluator": "RankBasedEvaluator",
    "evaluator_kwargs": {
      "filtered": true
    },
    "evaluation_kwargs": {
      "batch_size": null
    }
  },
  "optuna": {
    "n_trials": 3,
    "timeout": 1000,
    "metric": "mean_reciprocal_rank",
    "direction": "maximize",
    "sampler": "random",
    "pruner": "nop",
    "storage": "sqlite:////content/drive/MyDrive/NationsLiteral/0000_user_data_distmult/optuna_results.db",
    "save_model_directory": "/content/drive/MyDrive/NationsLiteral/0000_user_data_distmult/artifacts"
  }
}

```
I get the following error:
```python-traceback
File "/usr/local/lib/python3.7/dist-packages/pykeen/datasets/__init__.py", line 124, in get_dataset
    raise ValueError(f'dataset is neither a pre-defined dataset string nor a filepath: {dataset}')
ValueError: dataset is neither a pre-defined dataset string nor a filepath: NationsLiteral

```
I see that the 'NationsLiteral' dataset is not among the list of predefined datasets. Adding it there would fix the issue.

Additional Information:

I am actually interested in using my own data: 
Hence, it would be nice if we could provide the path to the numeric literals in the "hpo_config.json" file like the way the training/validation/testing sets are provided:

```
"training": "./drive/MyDrive/userdata/train.txt",
    "testing": "./drive/MyDrive/userdata/test.txt",
    "validation": "./drive/MyDrive/userdata/valid.txt", 
```
something that would look like this:

```
"numerical-triples": "./drive/MyDrive/userdata/literals.tsv",
```
that would be very easy to use with the CLI.  Looking forward to your reply on this. 

I have noticed one more bug with the main pipeline:

```python
from pykeen.pipeline import pipeline
from pykeen.datasets.nations import NationsLiteral

result = pipeline(
    dataset=NationsLiteral, 
    model='DistMultLiteral',
)
result.save_to_directory('./drive/MyDrive/')
```
returns the following error:

```python-traceback
/usr/local/lib/python3.7/dist-packages/torch/serialization.py in _save(obj, zip_file, pickle_module, pickle_protocol)
    474     pickler = pickle_module.Pickler(data_buf, protocol=pickle_protocol)
    475     pickler.persistent_id = persistent_id
--> 476     pickler.dump(obj)
    477     data_value = data_buf.getvalue()
    478     zip_file.write_record('data.pkl', data_value, len(data_value))

AttributeError: Can't pickle local object 'DistMultLiteral.__init__.<locals>.<lambda>'
```

I haven't checked it but there could also be the same error with the ComplExLiteral model. 

Thank you in advance.


@GenetAsefa I'd appreciate if you open a new issue and copy that over. Thanks!

@cthoyt I have divided the issue I have posted above into 3 and opened new separate issues and copied them there. Thanks.