code: def almost_eq(a, b, bits=32, tol=1, ignore_type=True, pad=0.):
    
    if not (ignore_type or type(a) == type(b)):
      return False
    is_it_a = isinstance(a, Iterable)
    is_it_b = isinstance(b, Iterable)
    if is_it_a != is_it_b:
      return False
    if is_it_a:
      return all(almost_eq.bits(ai, bi, bits, tol, ignore_type)
                 for ai, bi in xzip_longest(a, b, fillvalue=pad))
    significand = {32: 23, 64: 52, 80: 63, 128: 112
                  }[bits] # That doesn't include the sign bit
    power = tol - significand - 1
    return abs(a - b) <= 2 ** power * abs(a + b)
docs: Almost equal, based on the amount of floating point significand bits.
  
    Alternative to "a == b" for float numbers and iterables with float numbers,
    and tests for sequence contents (i.e., an elementwise a == b, that also
    works with generators, nested lists, nested generators, etc.). If the type
    of both the contents and the containers should be tested too, set the
    ignore_type keyword arg to False.
    Default version is based on 32 bits IEEE 754 format (23 bits significand).
    Could use 64 bits (52 bits significand) but needs a
    native float type with at least that size in bits.
    If a and b sizes differ, at least one will be padded with the pad input
    value to keep going with the comparison.
  
    Note
    ----
    Be careful with endless generators!