human
I wrote the below code

    (ssR, ssC) = subsample
    (OR, OC) = conv_out_shp(IR, IC, KR, KC, border_mode, subsample)
    rval = scipy_sparse.lil_matrix((((IR * IC) * CH), ((((OR * OC) * KR) * KC) * CH)))
    if (not flip_patches):
        raise NotImplementedError()
    def in_pos(i, j, k):
        return input_raster_order(i, j, k, IR, IC, CH)
    def out_pos(i, j, k):
        return output_raster_order(i, j, k, KR, KC, CH)
    for orow in range(OR):
        for ocol in range(OC):
            for krow in range(KR):
                for kcol in range(KC):
                    assert flip_patches
                    if (border_mode == 'valid'):
                        irow = ((((orow * ssR) + KR) - krow) - 1)
                        icol = ((((ocol * ssC) + KC) - kcol) - 1)
                    else:
                        irow = ((orow * ssR) - krow)
                        icol = ((ocol * ssC) - kcol)
                    if ((0 <= irow < IR) and (0 <= icol < IC)):
                        for ch in range(CH):
                            t = out_pos(krow, kcol, ch)
                            T = ((KR * KC) * CH)
                            try:
                                i = in_pos(irow, icol, ch)
                                j = ((((orow * OC) * T) + (ocol * T)) + t)
                                rval[(i, j)] = 1
                            except IndexError:
                                logger.error('{0}    {1}    {2}    {3}    {4}    {5}    {6}    {7}    {8}'.format(rval.shape, i, j, IR, IC, KR, KC, OR, OC))
                                raise
    return rval

What's a good function header?
assistant
#Here's a good function header.

def sp_extract_patches(IR, IC, KR, KC, CH, input_raster_order, output_raster_order, subsample, border_mode, flip_patches):