code: def iter_unary_patterns(
      pairs: Mapping[int, Set[Tuple[int, int]]],
  ) -> Iterable[PatternMatch]:
      r"""
      Yield unary patterns from pre-indexed triples.
  
      =============  ===============================
      Pattern        Equation
      =============  ===============================
      Symmetry       $r(x, y) \implies r(y, x)$
      Anti-Symmetry  $r(x, y) \implies \neg r(y, x)$
      =============  ===============================
  
      .. note ::
          By definition, we have confidence(anti-symmetry) = 1 - confidence(symmetry).
  
      :param pairs:
          A mapping from relations to the set of entity pairs.
  
      :yields: A pattern match tuple of relation_id, pattern_type, support, and confidence.
      """
      logger.debug(
          "Evaluating unary patterns: {symmetry, anti-symmetry}"
      )
      for r, ht in pairs.items():
          support = len(ht)
          rev_ht = {(t, h) for h, t in ht}
          confidence = len(ht.intersection(rev_ht)) / support
          yield PatternMatch(
              r, PATTERN_TYPE_SYMMETRY, support, confidence
          )
          # confidence = len(ht.difference(rev_ht)) / support = 1 - len(ht.intersection(rev_ht)) / support
          yield PatternMatch(
              r, PATTERN_TYPE_ANTI_SYMMETRY, support, 1 - confidence
          )
  
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 8 for calling a global function with example usage: iter_unary_patterns(pairs) without return types