def nonzero_columns(H):
    """
    Counts the number of columns in H not identically zero.

    Parameters
    ----------
    H : :py:class:`~sympy.matrices.dense.MutableDenseMatrix`
        A sympy matrix.

    Returns
    -------
    nonzero_cols : int
        The number of columns of A not indentically zero.

    Examples
    ---------
    >>> from sympy import Matrix, diag
    >>> A = Matrix([[0, 2],
    ...             [0, 4]])
    >>> nonzero_columns(A)
    1
    >>> nonzero_columns(Matrix.eye(5))
    5
    >>> nonzero_columns(diag(0,1,0,3,5,0))
    3
    """
    m, n = H.shape
    nonzero_cols = 0
    for j in range(0, n):
        for i in range(0, m):
            if H[i, j] != 0:
                nonzero_cols += 1
                break
    return nonzero_cols
