code: def filter_map_alignment(
      alignment: pandas.DataFrame,
      left: CoreTriplesFactory,
      right: CoreTriplesFactory,
      entity_offsets: torch.LongTensor,
  ) -> torch.LongTensor:
      """
      Convert dataframe with label or ID-based alignment.
  
      :param alignment: columns: EA_SIDES
          the dataframe with the alignment
      :param left:
          the triples factory of the left graph
      :param right:
          the triples factory of the right graph
      :param entity_offsets: shape: (2,)
          the entity offsets from old to new IDs
  
      :return: shape: (2, num_alignments)
          the ID-based alignment in new IDs
  
      :raises ValueError:
          if the datatype of the alignment data frame is imcompatible (neither string nor integer).
      """
      # convert labels to IDs
      for side, tf in zip(EA_SIDES, (left, right)):
          if isinstance(tf, TriplesFactory) and is_string_dtype(
              alignment[side]
          ):
              logger.debug(f"Mapping label-based alignment for {side}")
              # map labels, using -1 as fill-value for invalid labels
              # we cannot drop them here, since the two columns need to stay aligned
              alignment[side] = alignment[side].apply(
                  tf.entity_to_id.get, args=(-1,)
              )
          if not is_numeric_dtype(alignment[side]):
              raise ValueError(
                  f"Invalid dype in alignment dataframe for side={side}: {alignment[side].dtype}"
              )
  
      # filter alignment
      invalid_mask = (alignment.values < 0).any(axis=1) | (
          alignment.values
          >= numpy.reshape(
              numpy.asarray([left.num_entities, right.num_entities]),
              newshape=(1, 2),
          )
      ).any(axis=1)
      if invalid_mask.any():
          logger.warning(
              f"Dropping {format_relative_comparison(part=invalid_mask.sum(), total=alignment.shape[0])} "
              f"alignments due to invalid labels.",
          )
          alignment = alignment.loc[~invalid_mask]
  
      # map alignment from old IDs to new IDs
      return torch.as_tensor(
          alignment.to_numpy().T, dtype=torch.long
      ) + entity_offsets.view(2, 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 4 for calling a global function with example usage: filter_map_alignment(alignment, left, right, entity_offsets) and returns: unknown