human
Complete the below
@overload(np.linalg.matrix_power)
def matrix_power_impl(a, n):

    ''''Computes matrix power. Only integer powers are supported in numpy.'
    '''
assistant
#Here is the Python program you requested.
    _check_linalg_matrix(a, 'matrix_power')
    np_dtype = np_support.as_dtype(a.dtype)
    nt = getattr(n, 'dtype', n)
    if (not isinstance(nt, types.Integer)):
        raise TypeError('Exponent    must    be    an    integer.')
    def matrix_power_impl(a, n):
        if (n == 0):
            A = np.zeros(a.shape, dtype=np_dtype)
            for k in range(a.shape[0]):
                A[(k, k)] = 1.0
            return A
        if (n < 0):
            A = np.linalg.inv(a).copy()
            if (n == (-1)):
                return A
            n = (- n)
        else:
            if (n == 1):
                return a.copy()
            A = a
        if (n < 4):
            if (n == 2):
                return np.dot(A, A)
            if (n == 3):
                return np.dot(np.dot(A, A), A)
        else:
            acc = A
            exp = n
            flag = True
            while (exp != 0):
                if (exp & 1):
                    if flag:
                        ret = acc
                        flag = False
                    else:
                        ret = np.dot(ret, acc)
                acc = np.dot(acc, acc)
                exp = (exp >> 1)
            return ret
    return matrix_power_impl