class_docstr: Tests for testing the correctness of the base model fall back scoring functions.
class_docstr_tok: ["Tests","for","testing","the","correctness","of","the","base","model","fall","back","scoring","functions","."]
docstr: Check whether the output of optimized function matches the output of a repeated batch.
  
  .. note ::
      the repeated batch is created via :func:`pykeen.utils.extend_batch` and passed to
      :meth:`pykeen.models.base.Model.score_hrt`.
  
  :param score_func:
      the optimized score function, e.g., :meth:`pykeen.models.base.Model.score_t`
  :param dim:
      the dimension
docstr_tok: ["Check","whether","the","output","of","optimized","function","matches","the","output","of","a","repeated","batch",".","..","note",":",":","the","repeated","batch","is","created","via",":","func",":","`","pykeen.utils.extend_batch","`","and","passed","to",":","meth",":","`","pykeen.models.base.Model.score_hrt","`",".",":","param","score_func",":","the","optimized","score","function",",","e.g.",",",":","meth",":","`","pykeen.models.base.Model.score_t","`",":","param","dim",":","the","dimension"]
code: def _test(self, score_func: Callable, dim: Target) -> None:
      """
      Check whether the output of optimized function matches the output of a repeated batch.
  
      .. note ::
          the repeated batch is created via :func:`pykeen.utils.extend_batch` and passed to
          :meth:`pykeen.models.base.Model.score_hrt`.
  
      :param score_func:
          the optimized score function, e.g., :meth:`pykeen.models.base.Model.score_t`
      :param dim:
          the dimension
      """
      batch = torch.tensor(
          [[0, 0], [1, 0]], dtype=torch.long, device=self.device
      )
      hrt_batch = extend_batch(
          batch=batch,
          max_id=self.triples_factory.num_entities
          if dim != COLUMN_RELATION
          else self.triples_factory.num_relations,
          dim=dim,
      )
      optimized_output = score_func(batch).flatten()
      extended_output = self.model.score_hrt(
          hrt_batch=hrt_batch
      ).flatten()
      assert torch.allclose(optimized_output, extended_output)
  
imports: import unittest
  from dataclasses import dataclass
  from typing import Callable
  import torch
  from pykeen.datasets import Nations
  from pykeen.models import FixedModel, Model, TransE
  from pykeen.triples import TriplesFactory
  from pykeen.typing import COLUMN_HEAD, COLUMN_RELATION, COLUMN_TAIL, Target
  from pykeen.utils import extend_batch, resolve_device
label_desc: Use image node_id 2 for calling the TestBaseModelScoringFunctions obj's underlying member method code with example usage: obj._test(score_func, dim) without return types