def normalize_matrix(transformer, matrix):
    """Normalize count matrix to scale down the impact of very frequent tokens

    :param transformer: A Sklearn TfidfTransformer object
    :param matrix: An array representing a term document matrix,
    output of CountVectorizer.fit_transform
    """
    matrix_normalized = transformer.fit_transform(matrix)
    return matrix_normalized