class_docstr: A base module for KGE models.
  
  Subclasses of :class:`Model` can decide however they want on how to store entities' and
  relations' representations, how they want to be looked up, and how they should
  be scored. The :class:`OModel` provides a commonly used interface for models storing entity
  and relation representations in the form of :class:`pykeen.nn.Embedding`.
class_docstr_tok: ["A","base","module","for","KGE","models",".","Subclasses","of",":","class",":","`","Model","`","can","decide","however","they","want","on","how","to","store","entities","'","and","relations","'","representations",",","how","they","want","to","be","looked","up",",","and","how","they","should","be","scored",".","The",":","class",":","`","OModel","`","provides","a","commonly","used","interface","for","models","storing","entity","and","relation","representations","in","the","form","of",":","class",":","`","pykeen.nn.Embedding","`","."]
docstr: Initialize the module.
  
  :param triples_factory:
      The triples factory facilitates access to the dataset.
  :param loss:
      The loss to use. If None is given, use the loss default specific to the model subclass.
  :param loss_kwargs:
      keyword-based parameters passed to the loss instance upon instantiation
  :param predict_with_sigmoid:
      Whether to apply sigmoid onto the scores when predicting scores. Applying sigmoid at prediction time may
      lead to exactly equal scores for certain triples with very high, or very low score. When not trained with
      applying sigmoid (or using BCEWithLogitsLoss), the scores are not calibrated to perform well with sigmoid.
  :param random_seed:
      A random seed to use for initialising the model's weights. **Should** be set when aiming at reproducibility.
docstr_tok: ["Initialize","the","module",".",":","param","triples_factory",":","The","triples","factory","facilitates","access","to","the","dataset",".",":","param","loss",":","The","loss","to","use",".","If","None","is","given",",","use","the","loss","default","specific","to","the","model","subclass",".",":","param","loss_kwargs",":","keyword-based","parameters","passed","to","the","loss","instance","upon","instantiation",":","param","predict_with_sigmoid",":","Whether","to","apply","sigmoid","onto","the","scores","when","predicting","scores",".","Applying","sigmoid","at","prediction","time","may","lead","to","exactly","equal","scores","for","certain","triples","with","very","high",",","or","very","low","score",".","When","not","trained","with","applying","sigmoid","(","or","using","BCEWithLogitsLoss",")",",","the","scores","are","not","calibrated","to","perform","well","with","sigmoid",".",":","param","random_seed",":","A","random","seed","to","use","for","initialising","the","model","'s","weights",".","*","*","Should","*","*","be","set","when","aiming","at","reproducibility","."]
code: def __init__(
      self,
      *,
      triples_factory: KGInfo,
      loss: HintOrType[Loss] = None,
      loss_kwargs: Optional[Mapping[str, Any]] = None,
      predict_with_sigmoid: bool = False,
      random_seed: Optional[int] = None,
  ) -> None:
      """Initialize the module.
  
      :param triples_factory:
          The triples factory facilitates access to the dataset.
      :param loss:
          The loss to use. If None is given, use the loss default specific to the model subclass.
      :param loss_kwargs:
          keyword-based parameters passed to the loss instance upon instantiation
      :param predict_with_sigmoid:
          Whether to apply sigmoid onto the scores when predicting scores. Applying sigmoid at prediction time may
          lead to exactly equal scores for certain triples with very high, or very low score. When not trained with
          applying sigmoid (or using BCEWithLogitsLoss), the scores are not calibrated to perform well with sigmoid.
      :param random_seed:
          A random seed to use for initialising the model's weights. **Should** be set when aiming at reproducibility.
      """
      super().__init__()
  
      # Random seeds have to set before the embeddings are initialized
      if random_seed is None:
          logger.warning(
              "No random seed is specified. This may lead to non-reproducible results."
          )
          self._random_seed = None
      elif random_seed is not NoRandomSeedNecessary:
          set_random_seed(random_seed)
          self._random_seed = random_seed
  
      # Loss
      if loss is None:
          self.loss = self.loss_default(
              **(self.loss_default_kwargs or {})
          )
      else:
          self.loss = loss_resolver.make(loss, pos_kwargs=loss_kwargs)
  
      self.use_inverse_triples = triples_factory.create_inverse_triples
      self.num_entities = triples_factory.num_entities
      self.num_relations = triples_factory.num_relations
      self.relation_inverter = relation_inverter_resolver.make(
          query=None
      )
  
      self.predict_with_sigmoid = predict_with_sigmoid
  
imports: from __future__ import annotations
  import inspect
  import logging
  import os
  import pickle
  from abc import ABC, abstractmethod
  from typing import Any, ClassVar, Iterable, Mapping, Optional, Type, Union
  import torch
  from class_resolver import HintOrType
  from docdata import parse_docdata
  from torch import nn
  from ..inverse import RelationInverter, relation_inverter_resolver
  from ..losses import Loss, MarginRankingLoss, loss_resolver
  from ..triples import KGInfo
  from ..typing import LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, InductiveMode, MappedTriples, Target
  from ..utils import NoRandomSeedNecessary, get_preferred_device, set_random_seed
label_desc: Use image node_id 1 to create a new Model object from inherited base classes: nn, ABC with example: obj = Model()