code: def randomPairs(n_records: int, sample_size: int) -> IndicesIterator:
      """
      Return random combinations of indices for a square matrix of size n
      records. For a discussion of how this works see
      http://stackoverflow.com/a/14839010/98080
  
      """
      n: int = n_records * (n_records - 1) // 2
  
      if not sample_size:
          return iter([])
      elif sample_size >= n:
          random_pairs = numpy.arange(n)
      else:
          try:
              random_pairs = numpy.array(
                  random.sample(range(n), sample_size), dtype=numpy.uint
              )
          except OverflowError:
              return randomPairsWithReplacement(n_records, sample_size)
  
      b: int = 1 - 2 * n_records
  
      i = (-b - 2 * numpy.sqrt(2 * (n - random_pairs) + 0.25)) // 2
      i = i.astype(numpy.uint)
  
      j = random_pairs + i * (b + i + 2) // 2 + 1
      j = j.astype(numpy.uint)
  
      return zip(i, j)
  
imports: from __future__ import annotations
  import collections
  import itertools
  import random
  import sys
  import warnings
  from typing import Iterator, Tuple, overload
  import numpy
  import dedupe
  from dedupe._typing import DataInt, DataStr, Literal, RecordDict, RecordDictPair, RecordID, TrainingData
  from dedupe.canonical import getCanonicalRep
  from dedupe.core import unique
label_desc: Use image node_id 1 for calling a global function with example usage: randomPairs(n_records, sample_size) and returns: zip, iter, randomPairsWithReplacement