class_docstr: Cleanup a triples array by randomly selecting testing triples and recalculate to minimize moves.
  
  1. Calculate ``move_id_mask`` as in :func:`_prepare_cleanup`
  2. Choose a triple to move, recalculate ``move_id_mask``
  3. Continue until ``move_id_mask`` has no true bits
class_docstr_tok: ["Cleanup","a","triples","array","by","randomly","selecting","testing","triples","and","recalculate","to","minimize","moves",".","1",".","Calculate","``","move_id_mask","``","as","in",":","func",":","`","_prepare_cleanup","`","2",".","Choose","a","triple","to","move",",","recalculate","``","move_id_mask","``","3",".","Continue","until","``","move_id_mask","``","has","no","true","bits"]
code: def cleanup_pair(
      self,
      reference: MappedTriples,
      other: MappedTriples,
      random_state: TorchRandomHint,
  ) -> Tuple[MappedTriples, MappedTriples]:  # noqa: D102
      generator = ensure_torch_random_state(random_state)
      move_id_mask = _prepare_cleanup(reference, other)
  
      # While there are still triples that should be moved to the training set
      while move_id_mask.any():
          # Pick a random triple to move over to the training triples
          (candidates,) = move_id_mask.nonzero(as_tuple=True)
          idx = torch.randint(
              candidates.shape[0], size=(1,), generator=generator
          )
          idx = candidates[idx]
  
          # add to training
          reference = torch.cat(
              [reference, other[idx].view(1, -1)], dim=0
          )
          # remove from testing
          other = torch.cat([other[:idx], other[idx + 1 :]], dim=0)
          # Recalculate the move_id_mask
          move_id_mask = _prepare_cleanup(reference, other)
  
      return reference, other
  
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 1 for calling the RandomizedCleaner obj's underlying member method code with example usage: obj.cleanup_pair(reference, other, random_state) and returns: reference,  other