code: def build_representation_getter(
      relation: bool = False, index: int = 0
  ) -> Callable[[ERModel], Representation]:
      """
      Build a representation getter.
  
      :param relation:
          whether to get relation representations, or entity representations.
      :param index:
          the index of the representation to get
  
      :return:
          a function to get the representation.
      """
  
      def getter(model: ERModel) -> Representation:
          """
          Get a specific representation from model.
  
          :param model:
              the model
  
          :return:
              the representation
          """
          # cf. also https://github.com/pykeen/pykeen/issues/1071
          representations = (
              model.relation_representations
              if relation
              else model.entity_representations
          )
          return representations[index]
  
      return getter
  
file_path: pykeen/src/pykeen/pipeline/plot_utils.py
imports: import logging
  from typing import Callable, Mapping, Optional, Set
  from ..losses import loss_resolver
  from ..models.nbase import ERModel
  from ..nn.representation import Representation
  from ..stoppers import EarlyStopper
label_desc: Use image node_id 3 for calling a global function with example usage: build_representation_getter(relation, index) and returns: getter, representations