nodes: 0, module; 1, function_definition; 2, function_name:shuffle_sparse_matrix_and_labels; 3, parameters; 4, block; 5, identifier:matrix; 6, identifier:labels; 7, expression_statement; 8, print_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, print_statement; 15, return_statement; 16, comment:"""
    Shuffles a sparse matrix and set of labels together.
    Resorts to densifying and then re-sparsifying the matrix, for
    convenience.  Still very fast.
    """; 17, string:"Shuffling data"; 18, assignment; 19, assignment; 20, call; 21, call; 22, call; 23, string:"Data shuffled"; 24, expression_list; 25, identifier:new_matrix; 26, call; 27, identifier:rng_state; 28, call; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, attribute; 34, argument_list; 35, call; 36, call; 37, attribute; 38, argument_list; 39, attribute; 40, argument_list; 41, attribute; 42, identifier:shuffle; 43, identifier:new_matrix; 44, attribute; 45, identifier:set_state; 46, identifier:rng_state; 47, attribute; 48, identifier:shuffle; 49, identifier:labels; 50, identifier:SM32; 51, argument_list; 52, attribute; 53, argument_list; 54, identifier:matrix; 55, identifier:toDense; 56, attribute; 57, identifier:get_state; 58, identifier:numpy; 59, identifier:random; 60, identifier:numpy; 61, identifier:random; 62, identifier:numpy; 63, identifier:random; 64, identifier:new_matrix; 65, identifier:numpy; 66, identifier:asarray; 67, identifier:labels; 68, identifier:numpy; 69, identifier:random
code: def shuffle_sparse_matrix_and_labels(matrix, labels):
    """
    Shuffles a sparse matrix and set of labels together.
    Resorts to densifying and then re-sparsifying the matrix, for
    convenience.  Still very fast.
    """
    print "Shuffling data"
    new_matrix = matrix.toDense()
    rng_state = numpy.random.get_state()
    numpy.random.shuffle(new_matrix)
    numpy.random.set_state(rng_state)
    numpy.random.shuffle(labels)
  
    print "Data shuffled"
    return SM32(new_matrix), numpy.asarray(labels)