def build_pyramid(M, subsampling_factor=<NUM_LIT:3>):
subs = int(subsampling_factor)<EOL>if subs < <NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>N = [M]<EOL>while min(N[-<NUM_LIT:1>].shape) > <NUM_LIT:1>:<EOL><INDENT>N.append(bin_matrix(N[-<NUM_LIT:1>], subsampling_factor=subs))<EOL><DEDENT>return N<EOL>
Iterate over a given number of times on matrix M
    so as to compute smaller and smaller matrices with bin_dense.