I guess that parenthesis are missing:
`if not ( total_n_imgs == 1 and n_imgs == 1 ):`

but this would make more sense to me:
`if total_n_imgs is None or n_imgs < total_n_imgs:`