class_docstr: Add extra triples by swapping aligned entities.
class_docstr_tok: ["Add","extra","triples","by","swapping","aligned","entities","."]
code: def process(
      self,
      mapped_triples: MappedTriples,
      alignment: torch.LongTensor,
      offsets: torch.LongTensor,
  ) -> ProcessedTuple:  # noqa: D102
      # add swap triples
      # e1 ~ e2 => (e1, r, t) ~> (e2, r, t), or (h, r, e1) ~> (h, r, e2)
      # create dense entity remapping for swap
      dense_map = torch.full(
          size=(mapped_triples[:, 0::2].max().item() + 1,),
          fill_value=-1,
      )
      left_id, right_id = alignment
      dense_map[left_id] = right_id
      dense_map[right_id] = left_id
      # add swapped triples
      mapped_triples = torch.cat(
          [
              mapped_triples,
              # swap head
              swap_index_triples(
                  mapped_triples=mapped_triples,
                  dense_map=dense_map,
                  index=COLUMN_HEAD,
              ),
              # swap tail
              swap_index_triples(
                  mapped_triples=mapped_triples,
                  dense_map=dense_map,
                  index=COLUMN_TAIL,
              ),
          ],
          dim=0,
      )
      return ProcessedTuple(
          mapped_triples,
          alignment,
          dict(
              entity_offsets=offsets[:, 0],
              relation_offsets=offsets[:, 1],
          ),
      )
  
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 SwapGraphPairCombinator obj's underlying member method code with example usage: obj.process(mapped_triples, alignment, offsets) and returns: ProcessedTuple