class_docstr: A commonly useful base for KGEMs using embeddings and interaction modules.
  
  This model does not use post-init hooks to automatically initialize all of its
  parameters. Rather, the call to :func:`Model.reset_parameters_` happens at the end of
  ``ERModel.__init__``. This is possible because all trainable parameters should necessarily
  be passed through the ``super().__init__()`` in subclasses of :class:`ERModel`.
  
  Other code can still be put after the call to ``super().__init__()`` in subclasses, such as
  registering regularizers (as done in :class:`pykeen.models.ConvKB` and :class:`pykeen.models.TransH`).
  ---
  citation:
      author: Ali
      year: 2021
      link: https://jmlr.org/papers/v22/20-825.html
      github: pykeen/pykeen
docstr: Initialize the module.
  
  :param triples_factory:
      The triples factory facilitates access to the dataset.
  :param interaction: The interaction module (e.g., TransE)
  :param interaction_kwargs:
      Additional key-word based parameters given to the interaction module's constructor, if not already
      instantiated.
  :param entity_representations: The entity representation or sequence of representations
  :param entity_representations_kwargs:
      additional keyword-based parameters for instantiation of entity representations
  :param relation_representations: The relation representation or sequence of representations
  :param relation_representations_kwargs:
      additional keyword-based parameters for instantiation of relation representations
  :param skip_checks:
      whether to skip entity representation checks.
  :param kwargs:
      Keyword arguments to pass to the base model
docstr_tok: ["Initialize","the","module",".",":","param","triples_factory",":","The","triples","factory","facilitates","access","to","the","dataset",".",":","param","interaction",":","The","interaction","module","(","e.g.",",","TransE",")",":","param","interaction_kwargs",":","Additional","key-word","based","parameters","given","to","the","interaction","module","'s","constructor",",","if","not","already","instantiated",".",":","param","entity_representations",":","The","entity","representation","or","sequence","of","representations",":","param","entity_representations_kwargs",":","additional","keyword-based","parameters","for","instantiation","of","entity","representations",":","param","relation_representations",":","The","relation","representation","or","sequence","of","representations",":","param","relation_representations_kwargs",":","additional","keyword-based","parameters","for","instantiation","of","relation","representations",":","param","skip_checks",":","whether","to","skip","entity","representation","checks",".",":","param","kwargs",":","Keyword","arguments","to","pass","to","the","base","model"]
code: def __init__(
      self,
      *,
      triples_factory: KGInfo,
      interaction: HintOrType[
          Interaction[
              HeadRepresentation,
              RelationRepresentation,
              TailRepresentation,
          ]
      ],
      interaction_kwargs: OptionalKwargs = None,
      entity_representations: OneOrManyHintOrType[
          Representation
      ] = None,
      entity_representations_kwargs: OneOrManyOptionalKwargs = None,
      relation_representations: OneOrManyHintOrType[
          Representation
      ] = None,
      relation_representations_kwargs: OneOrManyOptionalKwargs = None,
      skip_checks: bool = False,
      **kwargs,
  ) -> None:
      """Initialize the module.
  
      :param triples_factory:
          The triples factory facilitates access to the dataset.
      :param interaction: The interaction module (e.g., TransE)
      :param interaction_kwargs:
          Additional key-word based parameters given to the interaction module's constructor, if not already
          instantiated.
      :param entity_representations: The entity representation or sequence of representations
      :param entity_representations_kwargs:
          additional keyword-based parameters for instantiation of entity representations
      :param relation_representations: The relation representation or sequence of representations
      :param relation_representations_kwargs:
          additional keyword-based parameters for instantiation of relation representations
      :param skip_checks:
          whether to skip entity representation checks.
      :param kwargs:
          Keyword arguments to pass to the base model
      """
      # TODO: support "broadcasting" representation regularizers?
      # e.g. re-use the same regularizer for everything; or
      # pass a dictionary with keys "entity"/"relation";
      # values are either a regularizer hint (=the same regularizer for all repr); or a sequence of appropriate length
      super().__init__(triples_factory=triples_factory, **kwargs)
      self.interaction = interaction_resolver.make(
          interaction, pos_kwargs=interaction_kwargs
      )
      self.entity_representations = self._build_representations(
          triples_factory=triples_factory,
          representations=entity_representations,
          representations_kwargs=entity_representations_kwargs,
          label="entity",
          skip_checks=skip_checks,
      )
      self.relation_representations = self._build_representations(
          triples_factory=triples_factory,
          representations=relation_representations,
          representations_kwargs=relation_representations_kwargs,
          label="relation",
          skip_checks=skip_checks,
      )
      # Comment: it is important that the regularizers are stored in a module list, in order to appear in
      # model.modules(). Thereby, we can collect them automatically.
      self.weight_regularizers = nn.ModuleList()
      # Explicitly call reset_parameters to trigger initialization
      self.reset_parameters_()
  
imports: from __future__ import annotations
  import logging
  from abc import ABC
  from collections import defaultdict
  from operator import itemgetter
  from typing import Any, ClassVar, Generic, Iterable, List, Literal, Mapping, Optional, Sequence, Tuple, Type, Union, cast
  import torch
  from class_resolver import HintOrType, OptionalKwargs
  from class_resolver.utils import OneOrManyHintOrType, OneOrManyOptionalKwargs, normalize_with_default
  from torch import nn
  from .base import Model
  from ..nn import representation_resolver
  from ..nn.modules import Interaction, interaction_resolver, parallel_unsqueeze
  from ..nn.representation import Representation
  from ..regularizers import Regularizer, regularizer_resolver
  from ..triples import KGInfo
  from ..typing import HeadRepresentation, InductiveMode, RelationRepresentation, TailRepresentation
  from ..utils import check_shapes, get_batchnorm_modules
label_desc: Use image node_id 1 to create a new ERModel object from inherited base classes: Generic, _NewAbstractModel with example: obj = ERModel()