human
I wrote the below code

    mx = None
    (r, c) = image_shape
    (pr, pc) = pool_shape
    (rs, cs) = pool_stride
    def last_pool(im_shp, p_shp, p_strd):
        rval = int(np.ceil((float((im_shp - p_shp)) / p_strd)))
        assert (((p_strd * rval) + p_shp) >= im_shp)
        assert (((p_strd * (rval - 1)) + p_shp) < im_shp)
        return rval
    last_pool_r = (last_pool(image_shape[0], pool_shape[0], pool_stride[0]) * pool_stride[0])
    required_r = (last_pool_r + pr)
    last_pool_c = (last_pool(image_shape[1], pool_shape[1], pool_stride[1]) * pool_stride[1])
    required_c = (last_pool_c + pc)
    for bc01v in get_debug_values(bc01):
        assert (not contains_inf(bc01v))
        assert (bc01v.shape[2] == image_shape[0])
        assert (bc01v.shape[3] == image_shape[1])
    wide_infinity = T.alloc((- np.inf), bc01.shape[0], bc01.shape[1], required_r, required_c)
    name = bc01.name
    if (name is None):
        name = 'anon_bc01'
    bc01 = T.set_subtensor(wide_infinity[:, :, 0:r, 0:c], bc01)
    bc01.name = ('infinite_padded_' + name)
    wide_infinity_count = T.alloc(0, bc01.shape[0], bc01.shape[1], required_r, required_c)
    bc01_count = T.set_subtensor(wide_infinity_count[:, :, 0:r, 0:c], 1)
    for row_within_pool in xrange(pool_shape[0]):
        row_stop = ((last_pool_r + row_within_pool) + 1)
        for col_within_pool in xrange(pool_shape[1]):
            col_stop = ((last_pool_c + col_within_pool) + 1)
            cur = bc01[:, :, row_within_pool:row_stop:rs, col_within_pool:col_stop:cs]
            cur.name = ((((('mean_pool_cur_' + bc01.name) + '_') + str(row_within_pool)) + '_') + str(col_within_pool))
            cur_count = bc01_count[:, :, row_within_pool:row_stop:rs, col_within_pool:col_stop:cs]
            if (mx is None):
                mx = cur
                count = cur_count
            else:
                mx = (mx + cur)
                count = (count + cur_count)
                mx.name = ((((('mean_pool_mx_' + bc01.name) + '_') + str(row_within_pool)) + '_') + str(col_within_pool))
   ...

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

def mean_pool(bc01, pool_shape, pool_stride, image_shape):