code: def index_pairs(
      triples: Iterable[Tuple[int, int, int]]
  ) -> Mapping[int, Set[Tuple[int, int]]]:
      """Create a mapping from relation to head/tail pairs for fast lookup."""
      rv: DefaultDict[int, Set[Tuple[int, int]]] = defaultdict(set)
      for h, r, t in triples:
          rv[r].add((h, t))
      return dict(rv)
  
imports: import hashlib
  import itertools
  import logging
  from collections import defaultdict
  from typing import Collection, DefaultDict, Iterable, Mapping, NamedTuple, Optional, Sequence, Set, Tuple, Union
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from .None import TriplesFactory
  from ..constants import COLUMN_LABELS, TARGET_TO_INDEX
  from ..typing import COLUMN_HEAD, COLUMN_RELATION, COLUMN_TAIL, LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, MappedTriples
label_desc: Use image node_id 6 for calling a global function with example usage: index_pairs(triples) and returns: dict