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
code: def score_r(
      self,
      ht_batch: torch.LongTensor,
      *,
      slice_size: Optional[int] = None,
      mode: Optional[InductiveMode] = None,
      relations: Optional[torch.LongTensor] = None,
  ) -> torch.FloatTensor:  # noqa: D102
      # normalize before checking
      if slice_size and slice_size >= self.num_relations:
          slice_size = None
      self._check_slicing(slice_size=slice_size)
  
      # slice early to allow lazy computation of target representations
      if slice_size:
          return torch.cat(
              [
                  self.score_r(
                      ht_batch=ht_batch,
                      slice_size=None,
                      mode=mode,
                      relations=torch.arange(
                          start=start,
                          end=min(
                              start + slice_size, self.num_relations
                          ),
                      ),
                  )
                  for start in range(0, self.num_relations, slice_size)
              ],
              dim=-1,
          )
  
      # add broadcast dimension
      ht_batch = ht_batch.unsqueeze(dim=1)
      h, r, t = self._get_representations(
          h=ht_batch[..., 0], r=relations, t=ht_batch[..., 1], mode=mode
      )
      # unsqueeze if necessary
      if relations is None or relations.ndimension() == 1:
          r = parallel_unsqueeze(r, dim=0)
      return repeat_if_necessary(
          scores=self.interaction(h=h, r=r, t=t),
          representations=self.relation_representations,
          num=self.num_relations
          if relations is None
          else relations.shape[-1],
      )
  
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 9 for calling the ERModel obj's underlying member method code with example usage: obj.score_r(ht_batch) and returns: repeat_if_necessary, torch