code: def cat_shift_triples(
      *triples: Union[CoreTriplesFactory, MappedTriples]
  ) -> Tuple[MappedTriples, torch.LongTensor]:
      """
      Concatenate (shifted) triples.
  
      :param triples:
          the triples factories, or mapped triples
  
      :return:
          a tuple `(combined_triples, offsets)`, where
          * `combined_triples`, shape: `(sum(map(len, triples)), 3)`, is the concatenation of the shifted mapped triples
            such that there is no overlap, and
          * `offsets`, shape: `(len(triples), 2)` comprises the entity & relation offsets for the individual factories
      """
      # a buffer for the triples
      res = []
      # the offsets
      offsets = torch.zeros(len(triples), 2, dtype=torch.long)
      for i, x in enumerate(triples):
          # normalization
          if isinstance(x, CoreTriplesFactory):
              e_offset = x.num_entities
              r_offset = x.num_relations
              x = x.mapped_triples
          else:
              e_offset = x[:, [0, 2]].max().item() + 1
              r_offset = x[:, 1].max().item() + 1
          # append shifted mapped triples
          res.append(x + offsets[None, i, [0, 1, 0]])
          # update offsets
          offsets[i + 1 :, 0] += e_offset
          offsets[i + 1 :, 1] += r_offset
      return torch.cat(res), offsets
  
imports: import logging
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from typing import Any, ClassVar, DefaultDict, Dict, Iterable, Mapping, NamedTuple, Optional, Sequence, Set, Tuple, Union
  import numpy
  import pandas
  import torch
  from class_resolver import ClassResolver
  from pandas.api.types import is_numeric_dtype, is_string_dtype
  from ...triples import CoreTriplesFactory, TriplesFactory
  from ...typing import COLUMN_HEAD, COLUMN_TAIL, EA_SIDE_LEFT, EA_SIDE_RIGHT, EA_SIDES, MappedTriples, TargetColumn
  from ...utils import format_relative_comparison, get_connected_components
label_desc: Use image node_id 1 for calling a global function with example usage: cat_shift_triples() and returns: torch,  offsets