def METHOD_NAME(x, lower=-1, upper=1):
    assert isinstance(x, sparse.csr_matrix)
    assert lower < upper
    l, n = x.shape
    feat_min = x.min(axis=0).toarray().flatten()
    feat_max = x.max(axis=0).toarray().flatten()
    coef = (feat_max - feat_min) / (upper - lower)
    coef[coef != 0] = 1.0 / coef[coef != 0]
    # (x - ones(l,1) * feat_min') * diag(coef) + lower
    # = x * diag(coef) - ones(l, 1) * (feat_min' * diag(coef)) + lower
    # = x * diag(coef) + ones(l, 1) * (-feat_min' * diag(coef) + lower)
    # = x * diag(coef) + ones(l, 1) * offset'
    offset = -feat_min * coef + lower
    offset[coef == 0] = 0
    if sum(offset != 0) * l > 3 * x.getnnz():
        print(
            "WARNING: The #nonzeros of the scaled data is at least 2 times larger than the original one.\n"
            "If feature values are non-negative and sparse, set lower=0 rather than the default lower=-1.",
            file=sys.stderr)
    return {'coef':coef, 'offset':offset}