def METHOD_NAME(x, scale_param):
    assert isinstance(x, sparse.csr_matrix)
    offset = scale_param['offset']
    coef = scale_param['coef']
    assert len(coef) == len(offset)
    l, n = x.shape
    if not n == len(coef):
        print("WARNING: The dimension of scaling parameters and feature number do not match.", file=sys.stderr)
        coef = coef.resize(n) # zeros padded if n > len(coef)
        offset = offset.resize(n)
    # scaled_x = x * diag(coef) + ones(l, 1) * offset'
    offset = sparse.csr_matrix(offset.reshape(1, n))
    offset = sparse.vstack([offset] * l, format='csr', dtype=x.dtype)
    scaled_x = x.dot(sparse.diags(coef, 0, shape=(n, n))) + offset
    if scaled_x.getnnz() > x.getnnz():
        print(
            "WARNING: original #nonzeros %d\n" % x.getnnz() +
            "       > new      #nonzeros %d\n" % scaled_x.getnnz() +
            "If feature values are non-negative and sparse, get scale_param by setting lower=0 rather than the default lower=-1.",
            file=sys.stderr)
    return scaled_x