<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def invert(a, b):
 """ The multiplicitive inverse of a in the integers modulo b. :return int: x, where a * x == 1 mod b """

    if HAVE_GMP:
        s = int(gmpy2.invert(a, b))
        # according to documentation, gmpy2.invert might return 0 on
        # non-invertible element, although it seems to actually raise an
        # exception; for consistency, we always raise the exception
        if s == 0:
            raise ZeroDivisionError('invert() no inverse exists')
        return s
    else:
        r, s, _ = extended_euclidean_algorithm(a, b)
        if r != 1:
            raise ZeroDivisionError('invert() no inverse exists')
        return s % b