code: def _prepare_cleanup(
      training: MappedTriples,
      testing: MappedTriples,
      max_ids: Optional[Tuple[int, int]] = None,
  ) -> torch.BoolTensor:
      """
      Calculate a mask for the test triples with triples containing test-only entities or relations.
  
      :param training: shape: (n, 3)
          The training triples.
      :param testing: shape: (m, 3)
          The testing triples.
      :param max_ids:
          The maximum identifier in each column. Calculates it automatically if not given.
  
      :return: shape: (m,)
          The move mask.
      """
      # base cases
      if len(testing) == 0:
          return torch.empty(0, dtype=torch.bool)
      if len(training) == 0:
          return torch.ones(testing.shape[0], dtype=torch.bool)
  
      columns = [[0, 2], [1]]
      to_move_mask = torch.zeros(1, dtype=torch.bool)
      if max_ids is None:
          max_ids = typing.cast(
              Tuple[int, int],
              tuple(
                  max(
                      training[:, col].max().item(),
                      testing[:, col].max().item(),
                  )
                  + 1
                  for col in columns
              ),
          )
      for col, max_id in zip(columns, max_ids):
          # IDs not in training
          not_in_training_mask = torch.ones(max_id, dtype=torch.bool)
          not_in_training_mask[training[:, col].view(-1)] = False
  
          # triples with exclusive test IDs
          exclusive_triples = (
              not_in_training_mask[testing[:, col].view(-1)]
              .view(-1, len(col))
              .any(dim=-1)
          )
          to_move_mask = to_move_mask | exclusive_triples
      return to_move_mask
  
imports: import logging
  import typing
  from abc import abstractmethod
  from typing import Collection, Optional, Sequence, Set, Tuple, Type, Union
  import numpy
  import pandas
  import torch
  from class_resolver.api import ClassResolver, HintOrType
  from ..constants import COLUMN_LABELS
  from ..typing import LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, MappedTriples, Target, TorchRandomHint
  from ..utils import ensure_torch_random_state
label_desc: Use image node_id 7 for calling a global function with example usage: _prepare_cleanup(training, testing, max_ids) and returns: to_move_mask, torch, torch