this line seems like the syntax is messed up.  is the comma after ref_count in the wrong place?  and do you need the + before img_arr.shape[1:]?