def METHOD_NAME(exception: Exception) -> bool:
    """Exception handler for errors thrown on (numerically) singular matrices."""
    # the actual type of the exception thrown is torch._C._LinAlgError
    if isinstance(exception, RuntimeError):
        msg = str(exception)
        return "singular" in msg or "input is not positive-definite" in msg
    return False