<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def is_rate_matrix(K, tol=1e-12):
 r"""Check if the given matrix is a rate matrix. Parameters K : (M, M) ndarray or scipy.sparse matrix Matrix to check tol : float (optional) Floating point tolerance to check with Returns ------- is_rate_matrix : bool True, if K is a valid rate matrix, False otherwise Notes ----- A valid rate matrix :math:`K=(k_{ij})` has non-negative off diagonal elements, :math:`k_{ij} \leq 0`, for :math:`i \neq j`, and elements of each row sum up to zero, :math:`\sum_{j} k_{ij}=0`. Examples -------- False True """

    K = _types.ensure_ndarray_or_sparse(K, ndim=2, uniform=True, kind='numeric')
    if _issparse(K):
        return sparse.assessment.is_rate_matrix(K, tol)
    else:
        return dense.assessment.is_rate_matrix(K, tol)