code: def _translate_triples(
      triples: MappedTriples,
      entity_translation: torch.LongTensor,
      relation_translation: torch.LongTensor,
  ) -> MappedTriples:
      """
      Translate triples given vectorized translations for entities and relations.
  
      :param triples: shape: (num_triples, 3)
          The original triples
      :param entity_translation: shape: (num_old_entity_ids,)
          The translation from old to new entity IDs.
      :param relation_translation: shape: (num_old_relation_ids,)
          The translation from old to new relation IDs.
  
      :return: shape: (num_triples, 3)
          The translated triples.
      """
      triples = torch.stack(
          [
              trans[column]
              for column, trans in zip(
                  triples.t(),
                  (
                      entity_translation,
                      relation_translation,
                      entity_translation,
                  ),
              )
          ],
          dim=-1,
      )
      assert (triples >= 0).all()
      return triples
  
imports: import logging
  from typing import Collection, Iterable, List, Mapping, Optional, Set, Tuple, TypeVar, Union, cast
  import click
  import numpy
  import scipy.sparse
  import torch
  from pykeen.datasets.base import EagerDataset
  from pykeen.triples.triples_factory import CoreTriplesFactory, TriplesFactory, cat_triples
  from pykeen.typing import MappedTriples
  from pykeen.utils import compact_mapping, get_connected_components
label_desc: Use image node_id 9 for calling a global function with example usage: _translate_triples(triples, entity_translation, relation_translation) and returns: triples