def METHOD_NAME(x, lwork, overwrite_a=False):
    """Mimic scipy.linalg.svd, avoid lwork and get_lapack_funcs overhead."""
    gesdd, gesvd = _get_lapack_funcs(x.dtype, ("gesdd", "gesvd"))
    # this has to use overwrite_a=False in case we need to fall back to gesvd
    u, s, v, info = gesdd(
        x, compute_uv=True, lwork=lwork[0], full_matrices=False, overwrite_a=False
    )
    if info > 0:
        # Fall back to slower gesvd, sometimes gesdd fails
        u, s, v, info = gesvd(
            x,
            compute_uv=True,
            lwork=lwork[1],
            full_matrices=False,
            overwrite_a=overwrite_a,
        )
    if info > 0:
        raise np.linalg.LinAlgError("SVD did not converge")
    if info < 0:
        raise ValueError("illegal value in %d-th argument of internal gesdd" % -info)
    return u, s, v