<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def top_proportions(mtx, n):
 """ Calculates cumulative proportions of top expressed genes Parameters mtx : `Union[np.array, sparse.spmatrix]` Matrix, where each row is a sample, each column a feature. n : `int` Rank to calculate proportions up to. Value is treated as 1-indexed, `n=50` will calculate cumulative proportions up to the 50th most expressed gene. """

    if issparse(mtx):
        if not isspmatrix_csr(mtx):
            mtx = csr_matrix(mtx)
        # Allowing numba to do more
        return top_proportions_sparse_csr(mtx.data, mtx.indptr, np.array(n))
    else:
        return top_proportions_dense(mtx, n)