class_docstr: A base class for combination of a graph pair into a single graph.
class_docstr_tok: ["A","base","class","for","combination","of","a","graph","pair","into","a","single","graph","."]
docstr: Combine two graphs using the alignment information.
  
  :param left:
      the triples of the left graph
  :param right:
      the triples of the right graph
  :param alignment: columns: LEFT | RIGHT
      the alignment, i.e., pairs of matching entities
  :param kwargs:
      additional keyword-based parameters passed to :meth:`TriplesFactory.__init__`
  
  :return:
      a single triples factory comprising the joint graph, as well as a tensor of pairs of matching IDs.
      The tensor of matching pairs has shape `(2, num_alignments)`, where `num_alignments` can also be 0.
docstr_tok: ["Combine","two","graphs","using","the","alignment","information",".",":","param","left",":","the","triples","of","the","left","graph",":","param","right",":","the","triples","of","the","right","graph",":","param","alignment",":","columns",":","LEFT","|","RIGHT","the","alignment",",","i.e.",",","pairs","of","matching","entities",":","param","kwargs",":","additional","keyword-based","parameters","passed","to",":","meth",":","`","TriplesFactory.__init__","`",":","return",":","a","single","triples","factory","comprising","the","joint","graph",",","as","well","as","a","tensor","of","pairs","of","matching","IDs",".","The","tensor","of","matching","pairs","has","shape","`","(","2",",","num_alignments",")","`",",","where","`","num_alignments","`","can","also","be","0","."]
code: def __call__(
      self,
      left: TriplesFactory,
      right: TriplesFactory,
      alignment: pandas.DataFrame,
      **kwargs,
  ) -> Tuple[TriplesFactory, torch.LongTensor]:
      """
      Combine two graphs using the alignment information.
  
      :param left:
          the triples of the left graph
      :param right:
          the triples of the right graph
      :param alignment: columns: LEFT | RIGHT
          the alignment, i.e., pairs of matching entities
      :param kwargs:
          additional keyword-based parameters passed to :meth:`TriplesFactory.__init__`
  
      :return:
          a single triples factory comprising the joint graph, as well as a tensor of pairs of matching IDs.
          The tensor of matching pairs has shape `(2, num_alignments)`, where `num_alignments` can also be 0.
      """
      # concatenate triples
      mapped_triples, offsets = cat_shift_triples(left, right)
      # filter alignment and translate to IDs
      alignment = filter_map_alignment(
          alignment=alignment,
          left=left,
          right=right,
          entity_offsets=offsets[:, 0],
      )
      # process
      # TODO: restrict to only using training alignments?
      mapped_triples, alignment, translation_kwargs = self.process(
          mapped_triples, alignment, offsets
      )
      if isinstance(left, TriplesFactory) and isinstance(
          right, TriplesFactory
      ):
          # merge mappings
          entity_to_id, relation_to_id = merge_label_to_id_mappings(
              left=left,
              right=right,
              **translation_kwargs,
          )
          triples_factory = TriplesFactory(
              mapped_triples=mapped_triples,
              entity_to_id=entity_to_id,
              relation_to_id=relation_to_id,
              **kwargs,
          )
      else:
          max_ids = mapped_triples.max(axis=0).values
          triples_factory = CoreTriplesFactory(
              mapped_triples=mapped_triples,
              num_entities=max_ids[0::2].max().item(),
              num_relations=max_ids[1].item(),
              **kwargs,
          )
  
      return triples_factory, alignment
  
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 the GraphPairCombinator obj's underlying member method code with example usage: obj.__call__(left, right, alignment) and returns: triples_factory,  alignment